【发布时间】:2014-04-24 16:39:19
【问题描述】:
我在我的 aspx 页面中有一个转发器控件,并且在该页面中我放置了复选框。当用户选中此框时,我想重定向到一个页面。我也编写了一个 javaScript 来执行此操作,如下所示:
js:
function update(eid) {
window.location("Events.aspx?eid="+eid);
}
以下是后面代码中的方法:
protected void rptEventReminder_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
CheckBox cbx = e.Item.FindControl("chkComplete") as CheckBox;
Label lbl = e.Item.FindControl("lblEid") as Label;
if (cbx != null && lbl !=null)
{
Int64 eid = Convert.ToInt64(lbl.Text);
cbx.Attributes.Add("onclick", "update(eid);");
}
}
我作为参数传递的那个 eid 在数据库中是唯一的。
我得到的 javaScript 错误是:
JavaScript 运行时错误:“eid”未定义
【问题讨论】:
-
试试这个:cbx.Attributes.Add("onclick", "update('"+eid+"');");
标签: c# jquery asp.net checkbox parameters