Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
//Server Side Code
[System.Web.Services.WebMethod]
public static string DeleteRow(int UserId)
{
string strmsg = string.Empty;
string ConStr = ConfigurationManager.ConnectionStrings["SqlCon"].ConnectionString;
SqlConnection con = new SqlConnection(ConStr);
SqlCommand cmd = new SqlCommand("delete from tblUser where MemberId=" + UserId, con);
con.Open();
//cmd.Parameters.AddWithValue("@Empid", empid);
int retval = cmd.ExecuteNonQuery();
con.Close();

if (retval == 1)
strmsg = "true";
else
strmsg = "false";

return strmsg;
}
--------------------------------------------------
\\webservice link button

sb.Append("\"<a href='ViewUserList.aspx?UserId=" + result.MemberId + "' ><span class='fa fa-trash'></a>\"");


--------------------------------------------------
<table class="table table-striped table-bordered table-hover dataTables-example" id="tblData">
                              <thead>
                                  <tr>
                                      <%--<th style="display:none;" >MemberId</th>--%>
                                      <th>UserName</th>
                                      <th>Email</th>
                                      <th>Phone</th>
                                      <th>Role</th>
                                      <th>Edit</th>
                                      <th><asp:LinkButton ID="btnDelete" Text="Delete Emp" runat="server" OnClientClick="DeleteConfirmbox(this.id);"></asp:LinkButton></th>
                          <asp:HiddenField ID="hdnMemberId" runat="server" Value='<%#Eval("MemberId") %>'></asp:HiddenField>


                                  </tr>
                              </thead>



                          </table>


What I have tried:

sb.Append("\"<a href='ViewUserList.aspx?UserId=" + result.MemberId + "' onclick = 'DeleteRow()' ><span class='fa fa-trash'></a>\"");
Posted
Updated 27-Jul-23 11:18am

1 solution

You're not specifying the name of the method in your service you want to call. If you're calling a method from a link you also need to make sure you've enabled HttpGet for your methods. The solutions to these are all detailed below

Possible to invoke ASMX service with parameter via url query string? - Stack Overflow[^]
 
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