1 回答
TA贡献1818条经验 获得超11个赞
如果你想根据确认框结果运行你的函数,试试这个代码
protected void GridViewActivities_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
lb.Attributes.Add("onclick", "var result = confirm('You are sure?'); if(result) { MyFunction(); } return true; ");
}
}
如果您想在不考虑确认框结果的情况下运行您的函数,请尝试以下代码:
protected void GridViewActivities_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
lb.Attributes.Add("onclick", "confirm('You are sure?'); MyFunction(); return true; ");
}
}
- 1 回答
- 0 关注
- 109 浏览
添加回答
举报