Sunday, 30 December 2012

Call server side method using javascript

Call server side method using javascript ServerSide Method:- 

System.Web.Services.WebMethod] public static string SetDownloadPath(string ID) {   
                     HttpContext.Current.Session["logo"] = ID; return ID; 


Javascript To Call:- 
PageMethods.SetDownloadPath(id);

 Need To change in Following:- 

EnablePageMethods="true"

Postback Page using Javascript in ASP.net

Postback Page using Javascript in ASP.net

For Calling Function:

__doPostBack('__Page', '');

Function:

function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }