我想在编辑运算符时坚持这个弹出窗口。问题是我return true
以便我可以访问代码隐藏,但是当这样做时,我的弹出窗口会立即关闭,如果我return false
:弹出窗口会粘住,但代码永远不会去代码隐藏。我该怎么办? (另外,我的链接按钮在转发器内)
JavaScript的:
function PopupEdit($this) {
if ($($this).attr("disabled") === "disabled") {
return false;
}
var module = $($this).parent().find("#modalEdit");
module.show();
window.onclick = function (event) {
if (event.target === module) {
module.hide();
}
};
return true; //Right here is the problem.
}
ASPX:
<asp:LinkButton CommandName="selectBtn" ToolTip="TRNSLTEdit" ID="btnEdit" CssClass="editOperator" runat="server" CommandArgument='<%# Eval("ID")%>' OnClientClick="return PopupEdit(this)">
<asp:Image ImageUrl="Images/Icons/Edit-16x16.png" ID="EditVisitor" runat="server" />
</asp:LinkButton>
C#:
protected void rptList_OnItemCommand(object source, RepeaterCommandEventArgs e)
{
var tellusUserId = TellusUser.UserID;
var operatorId = Convert.ToInt64(e.CommandArgument);
switch (e.CommandName)
{
case "selectBtn":
var btnEdit = (LinkButton)e.Item.FindControl("btnEdit");
btnEdit.Attributes.Add("onclick", "return false;"); //I tried this, but does not work.
var operatorsDataSet = _administrationSystem.GetOperatorForEdit(tellusUserId, operatorId);
if (operatorsDataSet != null)
{
ViewState["OperatorsForEdit"] = operatorsDataSet;
}
break;
}
}
答案 0 :(得分:1)
您的弹出窗口正在关闭,因为页面将转到服务器,因此弹出对话框已关闭。你必须从你的C#代码中的linkbutton点击事件中打开你的弹出窗口,你需要注册你的脚本
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "PopupEdit", "PopupEdit("+lnkControl.ClientID+");", true);
这将有效