-4
我是新来的Asp.net,但我想实施CellClick
事件为ASP的GridView, 像在Windows应用程序dataGridView1_CellClick()
。在asp.net中的CellClick事件
我是新来的Asp.net,但我想实施CellClick
事件为ASP的GridView, 像在Windows应用程序dataGridView1_CellClick()
。在asp.net中的CellClick事件
你可以添加一些jQuery到你的.aspx
页面。如果您想在服务器上处理某些内容,则可以从jQuery调用PageMethods.YourServerMethod
(例如,此代码片段为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;
}
嗨Mr_Green,感谢编辑,并放置在这个适当的方式 – MSR
你要问的问题。什么是你的问题 - 你有什么问题,你已经尝试过什么? –