我有一个GridView并实现了如下所示的RowDataBound事件
protected void gvwSearchResult_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int index = e.Row.RowIndex;
string IdValue = gvwSearchResult.DataKeys[index].Value.ToString();
Button _btnCheque = (Button)e.Row.FindControl("btnCheque");
_btnCheque .OnClientClick = "<script type='text/javascript'>if(confirm('Do you want to continue?')){window.location='Cheque.aspx?ID=" + IdValue.ToString()+"';}</script>";
}
}
当我点击按钮时,会抛出一个脚本错误。我的脚本格式化的任何想法?
答案 0 :(得分:0)
<script>
标记的内容(请参阅MSDN中的示例)... 答案 1 :(得分:0)
您不需要OnClientClick中的脚本标记 - 只需直接放置javascript。