Friday, March 29, 2013

How to call Webservice from c#

//Written in html.aspx in

 <script type="text/javascript">
        function CreateTest(Path) {
            var pageUrl = '<%=ResolveUrl("~/SitemapService.asmx")%>'
            var parameters = "{path:'" + Path + "'}";
            $.ajax({
                type: "POST",
                url: pageUrl + "/CreateXMLBreadCrum",
                data: parameters,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: OnSuccessCall,
                error: OnErrorCall
            });
        }
        function OnSuccessCall(response) {
            //alert('Hi');
        }
        function OnErrorCall(response) {
            //alert(response);
        }
    </script>

// CreateXMLBreadCrum is ametohd in a SitemapService.asmx

//Calling By C#
ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), System.Guid.NewGuid().ToString(), "CreateTest('sitemap/Web.sitemap');", true);



No comments:

Post a Comment