简体   繁体   English

在一个页面中使用相同的用户控件和模态弹出扩展器两次

[英]Using same user control with modal popup extender twice in one page

I am having a user control inside which i am using one user control twice. 我有一个用户控件,我在其中使用一个用户控件两次。 User control is with modal popup extender and search panel with gridview having select button. 用户控件是模态弹出扩展器和带有​​gridview的搜索面板,具有选择按钮。 When i click on select button, the user control should get closed. 当我单击选择按钮时,应该关闭用户控件。 For that, i am writing foll code 为此,我正在编写foll代码

protected void gvSearchResults_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            User usr = e.Row.DataItem as User;
            if (usr != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("document.getElementById('" + txtEmpId.ClientID + "').value = '" + usr.EmployeeId + "';");
                sb.Append("document.getElementById('" + txtEmpName.ClientID + "').value = '" + usr.FirstName + " " + usr.LastName + "';");
                sb.Append("$find('"+ ModalPopupExtender1.BehaviorID+"').hide();document.getElementById('" + txtEmployeeID.ClientID + "').value = '';document.getElementById('" + txtUserName.ClientID + "').value='';");

                LinkButton lnkSelect = e.Row.Cells[0].Controls[0] as LinkButton;
                lnkSelect.OnClientClick = sb.ToString();
                lnkSelect.Text = SelectString;
                e.Row.DataBind();
            }
        }
    }

In parent page, I am calling the user control like this 在父页面中,我正在调用这样的用户控件

<asp:TableCell>
                <asp:Label CssClass="editorLabel" ID="lblInstalledBy" runat="server" Text="Installed By:"></asp:Label>
            </asp:TableCell>
            <asp:TableCell>
                <CustomCTRL:CTRLSelectUser Width="155" ID="SelectUserInstBy" runat="server">
                </CustomCTRL:CTRLSelectUser>
            </asp:TableCell>
            <asp:TableCell />
            <asp:TableCell>
                <asp:Label CssClass="editorLabel" ID="lblOwner" runat="server" Text="Owner:"></asp:Label>
            </asp:TableCell>
            <asp:TableCell>
                <CustomCTRL:CTRLSelectUser Width="155" ID="CTRLSelectUserOwner" runat="server">
                </CustomCTRL:CTRLSelectUser>
            </asp:TableCell>

Now the issue is, this functionality works fine, for second usage, for the first use in parent page, the user control does not hide. 现在的问题是,这个功能工作正常,第二次使用,在父页面中第一次使用时,用户控件不会隐藏。

More information : the parent control is in update panel and child control too is in update panel , both having UpdateMode=conditional 更多信息:父控件位于更新面板中,子控件也位于更新面板中,两者都具有UpdateMode = conditional

Hope my question is clear! 希望我的问题很明确! Need help! 需要帮忙! Thanks in advance..have spent couple of days for this issue but did not find anything 在此先感谢..已经花了几天时间来解决这个问题,但没有找到任何结果

If you are determined to hide the modal with JS via the code behind file, you could do this: Step 1, create a JS function in the .aspx page like this: 如果你决定通过代码隐藏文件用JS隐藏模态,你可以这样做:第1步,在.aspx页面中创建一个JS函数,如下所示:

function HideModal() 
{
   $find("modalID").hide(); 
}

Then in your code behind, run the function on which ever event you want with this: 然后在你的代码中,运行你想要的事件的函数:

ClientScript.RegisterStartupScript(GetType(), "Javascript", "javascript:hideModal();", true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM