有人知道如何在ASP中从Gridview RowCommand事件中调用Javascript函数吗?
我需要调用函数来接收rowindex,但我不知道如何从rowcommand调用javascript函数
谢谢
发布于 2012-11-08 13:24:54
您可以使用ScriptManager调用它
ScriptManager.RegisterStartupScript(this, this.GetType(), "myalert", "alert('File already exists.');", true);您可以调用javascript函数来代替alert。
发布于 2012-11-08 13:53:20
protected void myGV_RowCommand(Object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "click1")
{
GridViewRow gvr = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
int RowIndex = gvr.RowIndex;
// now call the javascript function
Page.ClientScript.RegisterStartupScript(this.GetType(), "modalDialog", "CallJavaScriptFunction("+RowIndex +");", true);
}
if (e.CommandName == "click2")
{
Do something cool ...
}
}发布于 2012-12-18 15:15:54
如果你想调用一个JavaScript函数,这可能会对你有所帮助。
Page.ClientScript.RegisterStartupScript(this.GetType(),“调用我的函数”,"func()",true);
如果在脚本中使用jquery,不要忘记添加源jquery文件。
https://stackoverflow.com/questions/13282618
复制相似问题