JAVASCRIPT


Here I will explain how to integrate Web Methods through javascript with 5 steps.

Step1: We have to add meta tag in the Header of the Document
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

Step2: We have write function in server side like below; method name should be with webmethod tag like below
 $.ajax(
        {
            type: "POST",
            url: "CheckUser.aspx/CheckAccessRights",            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg)
                     {
                        //something
                        accessValue=msg;
                     }
        }
    );


Step3: We have to call the server side method from the client side
Step4: Add Script Tag, create one variable in as arrary
   <script language="javascript" type="text/javascript">
    var accessValue;
   <script/>
Step5: Create method from server side and add attribute [Webmethod] like below.

 [WebMethod]
    public string CheckAccessRights()
    {
        return "valid";
    }



No comments:

Post a Comment