如何在asp.net用户控件中使用jQuery ajax?

前端之家收集整理的这篇文章主要介绍了如何在asp.net用户控件中使用jQuery ajax?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在asp.net用户控件中使用ajax,
  1. $.ajax({
  2. type: "POST",url: "*TCSection.ascx/InsertTCSection",data: "{id:'" + id + "'}",contentType: "application/json; charset=utf-8",dataType: "json",success: function (msg) {
  3. var URL = msg.d;
  4. alert(URL);
  5. });

.cs代码

  1. [WebMethod]
  2. public static string InsertTCSection(string id)
  3. {
  4. string result = "deneme";
  5. return result;
  6. }

解决方法

您不能通过jquery调用保存在usercontrol中的方法.
因为.ascx控件不代表真实的url.

它们旨在嵌入到某些ASP.NET页面中,因此它们在运行时不存在.
你可能会做的是创建一个单独的服务并将你的方法放在那里.
webservices.

this,this和其他许多人

猜你在找的asp.Net相关文章