![]() |
|
|
|||||||
![]() |
ASP Net - How do I fire a server side button click event from javascript? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi,
I need to fire a server side button click event from my client side javascript. The client side javascript code follows: <script language="javascript" type="text/javascript"> function myFunction() { var strname; strname = prompt("What is your name", ""); form1.<%= hiddenTextField.ClientID %>.value = strname; form1.<% =btnSubmit.ClientID %>.click(); } </script> You can see that I'm trying to use the "click();" event for the <asp: "btnSubmit" button but it dosen't seem to work. Any ideas?! Thanks in advance for your help. Steve Steve Kershaw |
|
|
|
|
#2 |
|
Posts: n/a
|
the ModalPopup under ATlas Toolkit will do that for you ...
http://atlas.asp.net/atlastoolkit/Mo...odalPopup.aspx -- Bruno Alexandre (a Portuguese in Københanv, Danmark) "Steve Kershaw" <> escreveu na mensagem news: ups.com... > Hi, > > I need to fire a server side button click event from my client side > javascript. The client side javascript code follows: > > <script language="javascript" type="text/javascript"> > function myFunction() > { > var strname; > strname = prompt("What is your name", ""); > form1.<%= hiddenTextField.ClientID %>.value = strname; > form1.<% =btnSubmit.ClientID %>.click(); > > } > </script> > > You can see that I'm trying to use the "click();" event for the <asp: > "btnSubmit" button but it dosen't seem to work. > Any ideas?! > > Thanks in advance for your help. > > Steve > Bruno Alexandre |
|
|
|
#3 |
|
Posts: n/a
|
I'm sorry, maybe I didn't explain myself properly. I don't need a popup
that allows the user to enter some text (their name in this case). The javascript I displayed already does that: strname = prompt("What is your name", ""); What I need is, after the user enters their name and clicks the OK button on the javascript (client side) prompt popup, I need the javascript function to call a ( server side, ASP.NET, C# ) OnClick event.... Like this: form1.<% =btnSubmit.ClientID %>.click(); The server side event looks like: protected void btnSubmit_Click(object sender, EventArgs e) { TextBox2.Text = hiddenTextField.Value; Response.Write("Your name is: " + hiddenTextField.Value); } However, it dosen't work! Can anyone help?!! Steve Steve Kershaw |
|
|
|
#4 |
|
Posts: n/a
|
Hai Steve,
I hope u r button id is "btnSubmit" Step 1: In the server side page load event just add this code... Page.GetPostBackEventReference(ImageButton1) Step 2:- Try calling this line " __doPostBack('btnSubmit','OnClick');" call the above function "callPostBack" after u r prompt statement. eg:- <script language="javascript" type="text/javascript"> function myFunction() { var strname; strname = prompt("What is your name", ""); // if its a valid name then just call post back.. __doPostBack('btnSubmit','OnClick'); } </script> The java script will trigger a postback as if it was initiated by the Button.. u can handle it on u r server side hope this helps u Regards Vinu Vinu |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Asynchronous process from asp.net page button click event? | Ritha | Software | 0 | 09-29-2009 03:20 PM |
| How to activate Remote Assistance with XP using Windows Live Messenger | Oziisr | General Help Related Topics | 0 | 02-01-2008 04:45 PM |
| How to make your wonderful photo and video slideshow on DVD | kricww@gmail.com | DVD Video | 0 | 04-20-2006 07:26 AM |
| winsock.dll | J | A+ Certification | 7 | 07-20-2004 01:01 AM |
| Latest Tech Fiasco... | Ghost | A+ Certification | 30 | 01-09-2004 12:15 PM |