Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call a server-side method from JavaScript

Status
Not open for further replies.

neualex

Programmer
Feb 26, 2008
53
US
Folks,

In ASP.net (using C#), you can have a server control to call a defined method. (ie. You use a Button server control, you can call the OnClick method).

How can we call a defined method (on the server side) using JavaScript?

I have such requirement since when I have a dialog box on the client side (OK/Cancel message box), I need to call a defined method on the server side. (ie. Delete a record, accept a transaction, etc.)

Any suggestions/comments is appreciated. Thank you.

...neualex
 
you cannot. you need to use an ajax request to call a service/uri to return text to the client and then process the data on the client.

so in this case you want to move the code in the button's click event to either a static web/page method or webservice. for more information google webforms ajax.

as an FYI the asp:UpdatePanel is simply a full postback wrapped in an ajax call, so there is no preformance gain, or optimization with UpdatePanels.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top