最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - To show Modalpopup in JavaScript - Stack Overflow

programmeradmin1浏览0评论

I have a modal popup extender as follows

<div id="target" runat="server"></div>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID ="Modal"
    runat="server" TargetControlID="target"
    BackgroundCssClass="modalBackground"
    PopupControlID="Panel1"></cc1:ModalPopupExtender>

<asp:Panel ID="Panel1" runat="server">
  <asp:Login ID="Login1" Width="360px" Height="135px" BackColor="lightSteelBlue"
        LoginButtonStyle-BorderStyle="groove" TextBoxStyle-CssClass="textbox"
        LoginButtonStyle-CssClass="loginbutton" runat="server" >
    <TextBoxStyle CssClass="textbox" />
    <LoginButtonStyle BorderStyle="Groove" CssClass="loginbutton" />
  </asp:Login>
</asp:Panel>

On clicking on one button i have to show modalpopup. What code i can write in JavaScript to call modalpopup.Can anybody help.

I have a modal popup extender as follows

<div id="target" runat="server"></div>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID ="Modal"
    runat="server" TargetControlID="target"
    BackgroundCssClass="modalBackground"
    PopupControlID="Panel1"></cc1:ModalPopupExtender>

<asp:Panel ID="Panel1" runat="server">
  <asp:Login ID="Login1" Width="360px" Height="135px" BackColor="lightSteelBlue"
        LoginButtonStyle-BorderStyle="groove" TextBoxStyle-CssClass="textbox"
        LoginButtonStyle-CssClass="loginbutton" runat="server" >
    <TextBoxStyle CssClass="textbox" />
    <LoginButtonStyle BorderStyle="Groove" CssClass="loginbutton" />
  </asp:Login>
</asp:Panel>

On clicking on one button i have to show modalpopup. What code i can write in JavaScript to call modalpopup.Can anybody help.

Share Improve this question edited Apr 21, 2018 at 19:37 Stephen Docy 4,7887 gold badges21 silver badges31 bronze badges asked Aug 14, 2009 at 10:02 user42348user42348 4,32928 gold badges73 silver badges99 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 2
var modalDialog = $find("ModalPopupExtender1"); 
// get reference to modal popup using the AJAX api $find() function

  if (modalDialog != null) {
    modalDialog.show();
  }

The point of the ModalPopupExtender is that you do not have to write any JS. It does all the plumbing for you. You can look up the ASP.Net AJAX Controltoolkit Website for a manual on how to configure it: http://www.asp/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx

As Manu has already said, you don't need to write any javascript to trigger the popup.

All you need to do is drop a LinkButton onto the page and set that as the TargetControlID

<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID ="Modal"
    runat="server" TargetControlID="lbOpenModal"
    BackgroundCssClass="modalBackground"
    PopupControlID="Panel1"></cc1:ModalPopupExtender>


<asp:LinkButton id="lbOpenModal" runat="server" Text="Click me"></asp:LinkButton>

Then when you click the link, the modal will open.

发布评论

评论列表(0)

  1. 暂无评论