我有一个非常敏感的未解决的错误。 请看这个forums,
在asp:linkbutton上单击将打开一个modalPop,如果单击后退按钮,则浏览器会显示"文档已过期"
Linkbutton在gridview和命令中动态添加,点击动态添加的linkbutton" lnkBtnBookTheSelected_Click"函数将在那里调用我捕获选定的行ID。
bool CheckAvailability()
{
//some logical code and getting data in "statusList"
Session["Availability"] = statusList;
gridViewAvailability_DataBound(null,null);
}
protected void gridViewAvailability_DataBound(object sender, EventArgs e)
{
string[] statusList = (string[])Session["Availability"];
try
{
if (statusList.Length > 0)
{
int i = 1;
foreach (GridViewRow row in gridViewAvailability.Rows)
{
row.Cells[3].Controls.Clear();
if (statusList[i - 1] == "Available")
{
LinkButton lb = new LinkButton();
lb.Text = "Book this?";
lb.CommandArgument =i.ToString();
lb.Command+=lnkBtnBookTheSelected_Click;
row.Cells[3].Controls.Add(lb);
}
else
{
Label lbl = new Label();
lbl.Text ="Not available";
row.Cells[3].Controls.Add(lbl);
}
}
i++;
}
}
catch (Exception a)
{
}
}
protected void lnkBtnBookTheSelected_Click(object sender, CommandEventArgs e)
{
Session["SelectedID"] = e.CommandArgument.ToString();
lblUserMsgForPurpose.Text = "Dear " + Session["UserName"].ToString() + ", Please enter for what purpose you want to Booking";
ModalPopupExtenderPurpose.Show();//popup for some input
}
答案 0 :(得分:0)
来自浏览器的“文档已过期”消息可能是由于在发布表单后回击(单击后回发)。
我建议通过Javascript在ModalPopupExtender上调用show,而不是进行完整的回发。
<script type='text/javascript'>
function showPopup() {
$find('ModalPopupExtenderPurpose').show();
}
</script>
然后,在你的LinkButton标签中,添加onlick ='showPopup();返回0;'
<asp:LinkButton runat='server' id='lnkBtnBookTheSelected' Text='Show Popup' onclick='showPopup();return 0;' />
您可以在同一个javascript函数中操作所需的任何其他HTML。