Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to call the void parameterize function/method of server side from client side???

Suppose my server side parameterize void method is :-
protected void CreateDivSize(String eleId)
{
//code something write here.
}

I want to call that void method from client side(java scripts).

How will i do to solve that above problem...

Please Please help me anybody...
Posted

1 solution

You can define this method in an .asmx web service and call it via jQuery AJAX. The AJAX client side would look like this:

C#
var val = <value for="" eleid="">
jQuery.ajax({
                url: "service.asmx/CreateDivSize",
                type: "POST",
                data: '{"eleId":"' + val + '"}',
                contentType: "application/json; charset=utf-8"
            }).done(function (ds) {
            });</value>



You can execute this AJAX request on any event you want, but please note that I have not had a great luck using JQuery AJAX with ASP.NET because AJAX calls like these don't seem to update the view-state correctly so any ASP.NET postback that depends on the change to viewstate, for e.g. UpdatePanels, might behave weirdly.

Please make sure you take care using these 2 things together.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900