ModalPopupExtender

Last post 05-09-2008 2:53 PM by ramblor. 7 replies.

Sort Posts:

  • ModalPopupExtender

    05-09-2008, 9:29 AM

    Using the ModalPopUpExtender. I have a form and what I want to do is when user clicks the button and the transaction fails, the modal popup shows up to display the error message and this is the only time I need this to show up. How can I, from the server side, control the display or non-displaying of the modalpopupExtender in Ajax?

    .Net Web/Software Engineer
  • Re: ModalPopupExtender

    05-09-2008, 9:40 AM
    Answer
    • Loading...
    • eseidel
    • Joined on 10-17-2006, 2:03 PM
    • Indianapolis, Indiana
    • Posts 353

    Instead of using an actual form button to open the modalpopup, assign the targetcontrolid to a hidden(use style="display:none;", not visible=false as javascript can't see it then) asp:button. Then you can control it from code using .Show() and .Hide()

     Eric

  • Re: ModalPopupExtender

    05-09-2008, 9:42 AM
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 10:03 AM
    • Posts 559

    There's a ModalPopup.Show() method which can be used on the server-side. 

    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
  • Re: ModalPopupExtender

    05-09-2008, 12:36 PM

    Can you please  help me with some link to help me understand how to do this please???

    .Net Web/Software Engineer
  • Re: ModalPopupExtender

    05-09-2008, 12:40 PM
    Answer
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 10:03 AM
    • Posts 559

    If you need help with my suggestion, you just need to call the Show() method from your button click event, e.g.

    protected void Button1_Click(object sender, EventArgs e)
    {
        MyModalPopup.Show();
    }
    
     
     
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
  • Re: ModalPopupExtender

    05-09-2008, 1:41 PM
    Answer
    • Loading...
    • TCavins
    • Joined on 05-23-2007, 2:06 PM
    • Detroit, MI
    • Posts 62
    You still need to associate a button with your modal popup. Set its display="none" as in the following example: 

    <asp:Button id="btnButton" runat="server" style="display:none" />

    <ajaxToolkit:ModalPopupExtender

    ID="mpe" runat="server" PopupControlID="myPanel" TargetControlID="btnButton" DropShadow="false"  />

     In your code behind you can call mpe.Show() to display the modal popup and have another function call mpe.Hide() when you want it to disappear.

    Tim

  • Re: ModalPopupExtender

    05-09-2008, 2:34 PM

    Problem is it still fails to do what I need it to do. I want it to only show on Certain conditions and not on button click alone.

    Situation is as soon as I click on the Button, regardless of where I place the Modal.Show information, it shows.

    Like I have tried not setting the TargetControlID and then trying to set that in the Button Click when I am ready

    to call the click event but that does not happen at all as I get an exception for omitting the TargetControlID.

    How do I accomplish this using server side code??

     

    Below is my code

     

    <cc1:ModalPopupExtender

    BehaviorID="programmaticModalPopupBehavior"

    TargetControlID="BtnAddTransaction"

    ID="ProgrammaticModalPopUp"

    PopupControlID="WSMessenger"

    runat="server"

    DropShadow="False" CancelControlID="DivClose"

    BackgroundCssClass="modalBackground"

    >

    </
    cc1:ModalPopupExtender>

     

    <div id="WSMessenger" runat="server" style="display: none;width: 300px">

    <div style="float: right;">

    <asp:LinkButton ID="DivClose" runat="server">Close</asp:LinkButton>

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

    </div>

    <div id="WSMessageArea" runat="server">

     

    </div>

    </div>

     

     

     

    Protected Sub BtnAddTransaction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnAddTransaction.Click

    Dim InvalidTransactionNumber As String = "You have to log in to use this feature"

    If TransactionFlag = True Then

    Me.WSMessageArea.InnerHtml = InvalidTransactionNumber

    Me.ProgrammaticModalPopUp.TargetControlID = "BtnAddTransaction"

    ProgrammaticModalPopUp.Show()

    End If

    End Sub

    .Net Web/Software Engineer
  • Re: ModalPopupExtender

    05-09-2008, 2:53 PM
    Answer
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 10:03 AM
    • Posts 559

    You need the TargetControlID to be something other than BtnAddTransaction. Create a new button as suggested and set it's style to "display:none" or use a Hidden Field instead. Then you won't get the popup displayed when you click on BtnAddTransaction and you can call the Show() method on the server to show it.

    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Page 1 of 1 (8 items)