Javascript being called from ASP with c# codebehind.....Problemo

N

nazim

Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:


<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModalDialog(
"dialogBox.aspx", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQuery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS" runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>


BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.


Many Thanks guys, for your help, I dont know where else to turn!!!
 
J

Jason DeFontes

You can attach javascript to an asp button in the codebehind like this:

myButton.Attributes.Add("onclick", "openquery()");

-Jason
 
N

nazim

Jason DeFontes said:
You can attach javascript to an asp button in the codebehind like this:

myButton.Attributes.Add("onclick", "openquery()");

-Jason

I've actually used that and yes it allows me to call the java script
but ONLY when the I remove/comment out the <form> tags [as shown
below]. Now sorry if its a silly question but I need the form tag for
future server side processing?
I cant just omit them from the future webpage, thats why I was stuck.

Any ideas???


nazim said:
Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:


<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModalDialog(
"dialogBox.aspx", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQuery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS" runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>


BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.


Many Thanks guys, for your help, I dont know where else to turn!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top