C# asp.net中的CellClick事件
我是Asp.net新手,但我想为Asp的GridView实现CellClick事件,C# asp.net中的CellClick事件,c#,asp.net,C#,Asp.net,我是Asp.net新手,但我想为Asp的GridView实现CellClick事件, 就像在windows应用程序dataGridView1中一样,单击 您可以向.aspx页面添加一些jQuery。如果要在服务器上处理某些内容,可以从jQuery调用此代码段的PageMethods.YourServerMethod ex.SetName。SetName方法定义如下所示 <head runat="server"> <title></title>
就像在windows应用程序dataGridView1中一样,单击 您可以向.aspx页面添加一些jQuery。如果要在服务器上处理某些内容,可以从jQuery调用此代码段的PageMethods.YourServerMethod ex.SetName。SetName方法定义如下所示
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptMgr" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<div id="content" runat="server">
<asp:GridView ID="gridView" runat="server">
</asp:GridView>
</div>
</form>
<script type="text/javascript">
$("#gridView td").click(function () {
PageMethods.SetName("JavaScript!", onSuccessMethod, onFailMethod);
});
function onSuccessMethod(response) { alert(response); }
function onFailMethod() { }
</script>
</body>
您好,格林先生,谢谢您的编辑并以适当的方式放置此内容。您需要问一个问题。你的问题是什么?你有什么问题?你已经尝试了什么?
using System.Web.Services;
...
[WebMethod]
public static String SetName(string name)
{
return "This was called from " + name;
}