0

I have the following method which is called by asp button click.

protected void btn_saveDemographicsAddr_Click(object sender, ImageClickEventArgs e)
{
}

I want to call the above method using jquery ajax call with out page loading. I saw many blogs regarding this but i din't get the correct solutions.

Thanks in advance....

2
  • 1
    Which solutions did you see, and what wasn't correct about them? Commented Jul 22, 2013 at 12:07
  • sending button id to jQuery click event.. but that makes page load Commented Jul 22, 2013 at 12:10

3 Answers 3

1

I think UpdatePanel solve your problem. Just put your ImageButton control in UpdatePanel and Trigger onclick event, It automatically get your contain without page load.

This link help you more..

http://forums.asp.net/t/1817866.aspx/2/10

Sign up to request clarification or add additional context in comments.

Comments

0

You can use

Aspx

  <asp:ScriptManager ID="ScriptManagermAIN" EnablePageMethods="true" runat="server">
  </asp:ScriptManager>

c#

[WebMethod]
public void btn_saveDemographicsAddr_Click()
{
}

Javascript

PageMethods.btn_saveDemographicsAddr_Click();

For more info about scriptmanager go to scriptmanager

2 Comments

what about (object sender, ImageClickEventArgs e)
@RaghavendraDevraj Just add an html button and on click call javascript. Or on client click of your button execute javascript
0

Try Below Code:

     `About.aspx page
    using System.Web.Services;

    [WebMethod]
    public static string doSomething(int id)
    {
        return "hello";
    }

    $(document).ready(function () {
        $.ajax({
            type: "POST",
            url: "About.aspx/doSomething",
            data: "{'id':'1'}",
            dataType: "Json",
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                var returnedstring = data.d;
                ....
            }
        });
    });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.