title: how to call web service from a web-user control in asp.net?
body: <p>I have a web-user control, and i want to call the web-service from it. What is my main motive:</p>
  
  <p><strong>1. i am creating a web-user control for advanced search, for that i am adding the bound fields and buttons[Edit,Delete] dynamically to a gridview. 
  2. Now i am using the ajax to go edit and delete (there is specific reason to go for this approach as i have already mentioned that i am adding the boundfields and buttons dynamically, for that firstly i m clearing all the columns of grid then added the new ones. now if button's click fires then its post back the page and this make the buttons will disappear from the grid, so i want to use the Json for that)</strong></p>
  
  <p>Here is my code of grid::</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" CellPadding="4"
                  BorderWidth="1px" ForeColor="#333333" GridLines="None"&gt;
                  &lt;AlternatingRowStyle BackColor="White" /&gt;
                  &lt;FooterStyle BackColor="#990000" ForeColor="White" Font-Bold="True" /&gt;
                  &lt;HeaderStyle Height="30px" BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
                  &lt;PagerStyle ForeColor="#333333" HorizontalAlign="Center" BackColor="#E2E2E2" /&gt;
                  &lt;RowStyle CssClass="test" BackColor="#E2E2E2" Height="25px" BorderWidth="1px" ForeColor="#333333" /&gt;
                  &lt;SelectedRowStyle BackColor="#E2E2E2" Font-Bold="True" ForeColor="Navy" /&gt;
                  &lt;SortedAscendingCellStyle BackColor="#FDF5AC" /&gt;
                  &lt;SortedAscendingHeaderStyle BackColor="#4D0000" /&gt;
                  &lt;SortedDescendingCellStyle BackColor="#FCF6C0" /&gt;
                  &lt;SortedDescendingHeaderStyle BackColor="#820000" /&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is the code for Json call </p>
  
  <pre><code>$('.DeleteButton').live('click', function () {
          alert('hellllo');
          $.ajax({
              url: '&lt;%=ResolveUrl("~/Control/WebService/WebService.asmx/HelloWorld") %&gt;',
              data: "{ }",
              dataType: "json",
              type: "POST",
              contentType: "application/json;charset=utf-8",
              success: function () {
                  alert('hi;');
              },
              error: function () {
                  alert('Record could not be deleted. \n Please try again later. hye');
              },
              failure: function () {
                  alert('Record could not be deleted. \n Please try again later. hello');
              }
          });
      });
  </code></pre>
  
  <p>I am always getting the following Error:</p>
  
  <p><strong>500 internal Error</strong>
  please help me to get out of this prob i am stuck on it from last 2 days. </p>