rajeeva_nagaraj
asked on
Call Code behind method from javascript
Hi,
I have written a java script function which shows an alert message after some calculation, now i want to execute a code behind method (C# method) after that alert is shown.
Please its very urgent.
Regards
Rajeeva
I have written a java script function which shows an alert message after some calculation, now i want to execute a code behind method (C# method) after that alert is shown.
Please its very urgent.
Regards
Rajeeva
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you may use _doPostBack method to execute server side event..like
__doPostBack('ButtonID','' )
// if you are using master page than use <%= ButtonID.ClientID %>
for more info
http://wiki.asp.net/page.aspx/1082/dopostback-function/
__doPostBack('ButtonID',''
// if you are using master page than use <%= ButtonID.ClientID %>
for more info
http://wiki.asp.net/page.aspx/1082/dopostback-function/
You can use XML http for it ,it's goes in to server and do what ever you want....
ASKER
Hi All
I found solution, code behind method can be called from java script but using web methods
I found solution, code behind method can be called from java script but using web methods
function CallBackRequest(url,params
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLH
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.X
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange
{
if(xmlHttp.readyState==4)
Callback(xmlHttp.responseT
}
if(params== null)
{
xmlHttp.open("GET",url,tru
xmlHttp.send(null);
}
else
{
xmlHttp.open("POST",url,tr
xmlHttp.setRequestHeader("
xmlHttp.setRequestHeader("
xmlHttp.setRequestHeader("
xmlHttp.send(params);
}
}