Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - How do I fire a server side button click event from javascript?

 
Thread Tools Search this Thread
Old 05-27-2006, 07:38 AM   #1
Default How do I fire a server side button click event from javascript?


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
  Reply With Quote
Old 05-27-2006, 07:53 AM   #2
Bruno Alexandre
 
Posts: n/a
Default Re: How do I fire a server side button click event from javascript?
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
  Reply With Quote
Old 05-27-2006, 09:00 AM   #3
Steve Kershaw
 
Posts: n/a
Default Re: How do I fire a server side button click event from javascript?
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
  Reply With Quote
Old 05-27-2006, 12:10 PM   #4
Vinu
 
Posts: n/a
Default Re: How do I fire a server side button click event from javascript?
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46