| | |
Calling C# function through Javascript in ASP.NET
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
Not directly, no. Server-side functions live server-side, client-side functions live on the client.
In fact, the only way to get ANY server-side code to run, is to submit the form. ASP.NET unrolls the HTTP headers, unpackages the hidden ViewState variable, re-instantiates objects, and then decides what events to raise based on all of the above.
What you can do is have your JavaScript function set a hidden form variable, then do a form.submit().
Then, in your Page_Load handler on the server, use the Request object to check for the presence and/or value of this variable, and call the appropriate server-side method.
In fact, the only way to get ANY server-side code to run, is to submit the form. ASP.NET unrolls the HTTP headers, unpackages the hidden ViewState variable, re-instantiates objects, and then decides what events to raise based on all of the above.
What you can do is have your JavaScript function set a hidden form variable, then do a form.submit().
Then, in your Page_Load handler on the server, use the Request object to check for the presence and/or value of this variable, and call the appropriate server-side method.
•
•
Join Date: Jan 2009
Posts: 1
Reputation:
Solved Threads: 0
you can do this.
please visit this article . i thing it would be help full to you.
http://sappidireddy.wordpress.com/20...n-aspnet-ajax/
please visit this article . i thing it would be help full to you.
http://sappidireddy.wordpress.com/20...n-aspnet-ajax/
-1
#8 12 Days Ago
![]() |
Similar Threads
- ASP.NET and JavaScript (ASP.NET)
- How to transfer values between ASP.NET pages (ASP.NET)
- variables from javascript in asp.net (ASP.NET)
- help with asp.net/JS and cookies (ASP.NET)
- Javascript:How to transfer values between ASP.NET pages (JavaScript / DHTML / AJAX)
Other Threads in the ASP.NET Forum
- Previous Thread: Web services in .Net
- Next Thread: Pop up window
| Thread Tools | Search this Thread |
.net 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox class commonfunctions compatible confirmationcodegeneration content countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers







