-1

this is the aspx.cs page i want to hit the callme() method through ajax call

public void callme()
            {
                if (ddlApprovalType.SelectedValue == "1") // location
                {
                    BindDropdownlist(ddlLocation, "LOC");// LOC = Location
                }
                else if (ddlApprovalType.SelectedValue == "2") // process
                {
                    BindDropdownlist(ddlLocation, "LOC");// LOC = Location
                    ddlProcess.Items.Clear();
                    ddlSubProcess.Items.Clear();
                    ddlProcess.Items.Insert(0, new ListItem()
                    {
                        Value = "select",
                        Text = "---Select---",
                        Selected = true
                    });
                    ddlSubProcess.Items.Insert(0, new ListItem()
                    {
                        Value = "select",
                        Text = "---Select---",
                        Selected = true
                    });
                }

            }

this is my .aspx page

<asp:DropDownList runat="server" ID="ddlApprovalType" AutoPostBack="True" class="clsapprovalType" Style="font-family: arial;
                                    font-size: 13px; color: #353535; width: 200px; border: solid 1px #353535; background-color: transparent;" />



  <script type="text/javascript">
              $(".clsapprovalType").change(function () {
                  var approvalTypeVal = $j(this).val();
                  if (approvalTypeVal == "1") {
                      ("#trlocation").show();
                  }
               $.ajax({url:'mypage.aspx/callme', method:get});
              });
        </script>

how to hit callme() method through $.ajax in asp.net using jquery without using update panel?

3
  • 1
    Either setup an HttpHandler, or have a look at WebMethods Commented Oct 5, 2015 at 10:49
  • @Andrei: Eventhough OP uses a webmethod. Will it be possible to access server controls inside an Webmethod ? Commented Oct 5, 2015 at 11:06
  • @Suprabhat, of course not. Then OP will need to change the way response if used. But i see the point, update panel might be a better option here Commented Oct 5, 2015 at 11:10

1 Answer 1

0

first thing you need to know ajax will make calls for only static methods. ultimately you cannot access page level controls in static method. so you have to pass parameters and return the o/p to client side and manipulate DOM at client side code i.e.., inside ajax success function.

for ajax calls it is already answered in many posts. You can go through this reference

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

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.