How to call MasterPage WebMehod using jQuery Ajax in ASP.Net

Last Reply on May 11, 2017 04:17 AM By dharmendr

Posted on May 06, 2017 01:54 AM

dear sir

in my master page there is user form where user can fill the form

i tryed to use jquery ajax to call my master page [WebMethod] saveReminder() but this method is not calling

<aside class="control-sidebar control-sidebar-dark">
  <!-- Content of the sidebar goes here -->
    <!-- Create the tabs -->
    <ul class="nav nav-tabs nav-justified control-sidebar-tabs">
      <li class="active"><a href="#control-sidebar-home-tab" data-toggle="tab"><i class="fa fa-home"></i></a></li>
      <li><a href="#control-sidebar-settings-tab" data-toggle="tab"><i class="fa fa-edit"></i></a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
      <!-- Home tab content -->
      <div class="tab-pane" id="control-sidebar-home-tab">
        <h3 class="control-sidebar-heading">Recent Activity</h3>
        <ul class="control-sidebar-menu">
          <li>
            <a href="javascript:void(0)">
              <i class="menu-icon fa fa-birthday-cake bg-red"></i>

              <div class="menu-info">
                <h4 class="control-sidebar-subheading">Langdon's Birthday</h4>

                <p>Will be 23 on April 24th</p>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <i class="menu-icon fa fa-user bg-yellow"></i>

              <div class="menu-info">
                <h4 class="control-sidebar-subheading">Frodo Updated His Profile</h4>

                <p>New phone +1(800)555-1234</p>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <i class="menu-icon fa fa-envelope-o bg-light-blue"></i>

              <div class="menu-info">
                <h4 class="control-sidebar-subheading">Nora Joined Mailing List</h4>

                <p>nora@example.com</p>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <i class="menu-icon fa fa-file-code-o bg-green"></i>

              <div class="menu-info">
                <h4 class="control-sidebar-subheading">Cron Job 254 Executed</h4>

                <p>Execution time 5 seconds</p>
              </div>
            </a>
          </li>
        </ul>
        <!-- /.control-sidebar-menu -->

        <h3 class="control-sidebar-heading">Tasks Progress</h3>
        <ul class="control-sidebar-menu">
          <li>
            <a href="javascript:void(0)">
              <h4 class="control-sidebar-subheading">
                Custom Template Design
                <span class="label label-danger pull-right">70%</span>
              </h4>

              <div class="progress progress-xxs">
                <div class="progress-bar progress-bar-danger" style="width: 70%"></div>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <h4 class="control-sidebar-subheading">
                Update Resume
                <span class="label label-success pull-right">95%</span>
              </h4>

              <div class="progress progress-xxs">
                <div class="progress-bar progress-bar-success" style="width: 95%"></div>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <h4 class="control-sidebar-subheading">
                Laravel Integration
                <span class="label label-warning pull-right">50%</span>
              </h4>

              <div class="progress progress-xxs">
                <div class="progress-bar progress-bar-warning" style="width: 50%"></div>
              </div>
            </a>
          </li>
          <li>
            <a href="javascript:void(0)">
              <h4 class="control-sidebar-subheading">
                Back End Framework
                <span class="label label-primary pull-right">68%</span>
              </h4>

              <div class="progress progress-xxs">
                <div class="progress-bar progress-bar-primary" style="width: 68%"></div>
              </div>
            </a>
          </li>
        </ul>
        <!-- /.control-sidebar-menu -->

      </div>
      <!-- /.tab-pane -->
      <!-- Stats tab content -->
      <div class="tab-pane" id="control-sidebar-stats-tab">Stats Tab Content</div>
      <!-- /.tab-pane -->
      <!-- Settings tab content -->
      <div class="tab-pane" id="control-sidebar-settings-tab">
        <div>
          <h3 class="control-sidebar-heading">Create Reminder</h3>

          <div class="form-group">
            <label class="control-sidebar-subheading">
              Date
             <%-- <input type="checkbox" class="pull-right" checked>--%>
              <asp:TextBox ID="txtRmdDate" class="form-contorl pull-right" runat="server"></asp:TextBox>
            </label>
          </div>
          <!-- /.form-group -->
             <div class="form-group">
            <label class="control-sidebar-subheading">
              Time
              <asp:TextBox ID="txtRmdTime" class="form-contorl pull-right" runat="server"></asp:TextBox>
</label>
            
          </div>
              <div class="form-group">
            <label class="control-sidebar-subheading">
              Ticket No </label>
             <asp:DropDownList ID="ddlTicketNo" class="form-control"  runat="server"></asp:DropDownList>
          </div> 
          <!-- /.form-group -->
              <div class="form-group">
                  <label>Reminder Details</label>
                  <asp:TextBox class="form-control" TextMode="MultiLine"  Rows="3" placeholder="Enter Details...." ID="txtrmdDetails" runat="server"></asp:TextBox>
                </div>
              <div class="form-group">
                <%-- <asp:Button ID="Button1" class="form-control btn btn-info"  runat="server" OnClientClick="myfunction(); return false;"  Text="Create Reminder" /> --%>
                  <input id="btnTicketReminder" type="button" class="form-control btn btn-info" value="Create Reminder" />
                  <asp:Button ID="Button1" runat="server" Text="Button" />
                    </div>
        </div>
      </div>
        <script>
            $(document).ready(function(){
                $("#btnTicketReminder").click(function () {
                    $.ajax({
                        type: "POST",
                        url: "MasterPage.master/saveReminder",
                        data: "{}",
                        dataType: "json",
                        success: OnSuccess,
                        failure: function (response)
                        {
                            alert(response.d);
                        }
                    });
                });
            });
        </script>
      <!-- /.tab-pane -->
    </div>
</aside>
<!-- The sidebar's background -->

 

 [WebMethod]
    public static void saveReminder() 
    {
        DataUtility.SendAlert("hello world ");
    }

 

Posted on May 06, 2017 01:54 AM
Hi @amitsinghr,
Please try the following

Check UserName availability in MasterPage using jQuery AJAX in ASP.Net

It might help you.

Cheers Andrea.