无法在子页面中调用母版页的模式弹出窗口
我正在使用模式弹出窗口来显示登录框。模式弹出窗口位于主页中,并与其中的登录链接相关联。现在我想使用不同的链接按钮在子页面中调用相同的模式弹出窗口。模态弹出窗口可以通过母版页的登录链接调用,但我想在子页面中添加第二个控件(linkButton),它可以调用母版页的模态弹出窗口。
我在子页面中尝试过此操作:
function LogIn2()
{
$find("programmaticModalPopupBehavior").show();
}
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="LogIn2">Log in</asp:LinkButton>
参考:用于 ModalPopup 的多个 TargetControls
如何调用从子页面中的控件弹出母版页的功能模式?
更新:
这是在母版页中:
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="linkLog" CancelControlID="linkClose" BackgroundCssClass="cssModal" PopupControlID="panelPopUp" BehaviorID="programmaticModalPopupBehavior" PopupDragHandleControlID="panelDrag"></ajax:ModalPopupExtender>
I am using a modal popup for to display login box. The modal popup is in the master page and associated with a LogIn link therein. Now I want to call the same modal popup in a child page using a different link button. The modal popup can be called by the LogIn link of master page but I want to add this second control (linkButton) in child page, which can call the modalpop of master page.
I tried this in child page:
function LogIn2()
{
$find("programmaticModalPopupBehavior").show();
}
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="LogIn2">Log in</asp:LinkButton>
Reference: multiple TargetControls for the ModalPopup
How to call the functional modal popup of master page from a control in child page??
Update:
This is in masterpage:
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="linkLog" CancelControlID="linkClose" BackgroundCssClass="cssModal" PopupControlID="panelPopUp" BehaviorID="programmaticModalPopupBehavior" PopupDragHandleControlID="panelDrag"></ajax:ModalPopupExtender>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为 LinkButton 添加 OnClientClick,如下所示:
将 JavaScript 函数放入母版页中,并在显示弹出窗口后,让该方法返回 false 以防止 LinkButton 进行回发:
作为替代方案,您还可以将 return false 添加到LogIn2 函数执行后,LinkButton 的 OnClientClick,如下所示:
Add an OnClientClick for the LinkButton, like this:
Put the JavaScript function in your master page, and after showing the popup, have the method return false to prevent the LinkButton from doing a postback:
As an alternative, you may also add return false to the OnClientClick of the LinkButton, after the LogIn2 function has executed, like this:
我对此不确定,但让我确认一下您是否使用了 ajax 控件,如下所示
如果是,那么您可以使用具有不同名称的相同模式,如果这不起作用,请告诉我,我会尽力尝试
这个,如果可以的话有效
并添加这个
I m not sure about this but let me confirm are you using the control of ajax like given below
If Yes then you can use this same modal with a different name, If this doesnt work let me know I will try my best
try this if it works
and add this as well