<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input type="button" id="Button2" runat="server" value="Button" />
</div>
[WebMethod()]
[ScriptMethod()]
public static void myMethod(string text)
{
Label1.text=text;
}
$(document).ready(function () {
$("#Button2").click(function () {
var text = $("#TextBox1").val();
$.ajax({
type: "POST",
url: "WebForm1.aspx/myMethod",
data: "{ text: '" + text + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "true",
cache: "false",
success: function (msg) {
alert("success");
},
Error: function (x, e) {
// On Error
});
<UC:userControl id="control1" runat="server" />
<%@ Register TagPrefix="UC" TagName="userControl " src="~/Controls/Mycontrol.ascx" %>
i tried url value(s) like <pre> url: "Mycontrol.ascx/myMethod",
<pre> url: "WebForm1.aspx/Mycontrol.ascx/myMethod",