PC Review


Reply
Thread Tools Rate Thread

How to call server side function for client side JavaScript?

 
 
=?Utf-8?B?bGFuZW0=?=
Guest
Posts: n/a
 
      30th Mar 2005
I want to call a server-side function, like a button's click event, from a
client-side JavaScript function. How do I do that? Thanks.
 
Reply With Quote
 
 
 
 
JV
Guest
Posts: n/a
 
      30th Mar 2005
In order to call server-side code you have to post back to the web server.
If you examine the HTML that is generated on a simple web page with a
button, you will get a pretty good idea how to do that. It's just calling a
javascript that ASP.NET automatically generates in your web page.


"lanem" <(E-Mail Removed)> wrote
>I want to call a server-side function, like a button's click event, from a
> client-side JavaScript function. How do I do that? Thanks.



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      30th Mar 2005
Lanem:
Your question is a little vague..if you just want to dynamically trigger a
postback, you can use the __doPostback function:

<asp:button id="x" runat="server" />
<a href="javascript:__doPostBack('x', '');">hahah I'm sooo clever!</a>

If you only have Buttons and no LinkButtons or other controls which require
__doPostBack, you'll have to trick the page into generating the Javascript
for you (button's don't need javascript)...you can use
Page.GetPostBackClientEvent(x, ""); where x is the id of the button
control.

the above <a tag will cause x's click event to fire in codebehind.

If you want to fire server-side code without generating a postback, you'll
need to look at XmlHTTP, here's a good link dump:
http://www.quirksmode.org/blog/archi...p_linkdum.html


Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"lanem" <(E-Mail Removed)> wrote in message
news:A215F207-D048-4650-AC64-(E-Mail Removed)...
> I want to call a server-side function, like a button's click event, from a
> client-side JavaScript function. How do I do that? Thanks.



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      30th Mar 2005
Do you mean you want to fire a server-side event?

Eliyahu

"lanem" <(E-Mail Removed)> wrote in message
news:A215F207-D048-4650-AC64-(E-Mail Removed)...
> I want to call a server-side function, like a button's click event, from a
> client-side JavaScript function. How do I do that? Thanks.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to call server side function from client side code in asp.net? Simon Microsoft ASP .NET 5 30th Apr 2008 07:08 AM
How to call Server Side function from Client Side Code usingPageMethods in ASP.NET AJAX Ketki Microsoft C# .NET 0 21st Feb 2008 11:44 AM
I want to call a function in server side from the client side =?Utf-8?B?UmFtYWtyaXNobmFuIE5hZ2FyYWphbg==?= Microsoft VB .NET 2 8th Sep 2005 01:14 PM
How to call Server side Function from client side function ? Ing. Rajesh Kumar Microsoft ASP .NET 2 30th Mar 2004 09:16 PM
How to call server side (VB/C#) function from client side (Javascript)? =?Utf-8?B?ZGR0?= Microsoft ASP .NET 3 12th Mar 2004 11:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:21 AM.