我在后面的代码中使用 Response.Write 在客户端中运行 javascript,它在RowCommand
gridview 事件中触发:
protected void RowCommand(object sender, GridViewCommandEventArgs e)
{
var index = int.Parse(e.CommandArgument.ToString());
var val = gvwCus.DataKeys[index][0].ToString();
PopupWindow("../Main/Detail.aspx?idc=" + val,900.ToString(),600.ToString());
}
private void PopupWindow(string query, string width, string height)
{
var re = "<script language=\"javascript\">var left=(screen.width/2)-(" + width +"/2); var top=(screen.height/2)-(" + height + "/2); window.open(" + query +",'PopUp','toolbar=no, location=0, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=" + width + ", height=" + height + ",top=' + top + ',left=' + left);</script>";
Response.Write(re);
}
我在客户端编写了相同的代码,它运行正常,但在后面的代码中,它不起作用。