ModalpopupExtender TargetControl

Last post 01-07-2009 3:24 AM by Vince Xu - MSFT. 2 replies.

Sort Posts:

  • ModalpopupExtender TargetControl

    01-06-2009, 1:03 AM
    • Member
      50 point Member
    • khalid2008
    • Member since 03-10-2008, 12:53 PM
    • Posts 197

    Hi All,

    I want to check condition in TargetControl's codebehind and if the case is true I will sho the popup,Is this possible????

    if yes, how can I do that???

    thanks

    khalid 

     

  • Re: ModalpopupExtender TargetControl

    01-06-2009, 2:08 AM
    Answer
    • All-Star
      124,769 point All-Star
    • XIII
    • Member since 07-01-2002, 3:59 AM
    • Essen, Belgium
    • Posts 13,760
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Hi,

    yes, this is possible. Take a look at the answer (the shiny source code) that I provided in this thread: http://forums.asp.net/t/1365393.aspx.

    Grz, Kris.

  • Re: ModalpopupExtender TargetControl

    01-07-2009, 3:24 AM
    Answer

    Hello,

    Based on my understanding, you want to do validation in the click event of TargetControl and pop out the ModalPopup if it satisfies the certain conditions.

    In this way, we can build a dummy button as the TargetControl.

    Please check the below sample.

    <head runat="server">
        <title>Untitled Page</title>
        <style>
            .modalBackground
            {
                background-color: Gray;
                filter: alpha(opacity=70);
                opacity: 0.7;
            }
            .modalPopup
            {
                background-color: #ffffdd;
                border-width: 3px;
                border-style: solid;
                border-color: Gray;
                padding: 3px;
                width: 250px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1">
        </ajaxToolkit:ToolkitScriptManager>
        <asp:Button ID="loginButton" runat="server" Text="login" OnClick="loginButton_Click" /><br />
        <asp:Button runat="server" ID="hiddenTargetControlForModalPopup" Style="display: none" />
        <ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior"
            TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="programmaticPopup"
            BackgroundCssClass="modalBackground" DropShadow="True" RepositionMode="RepositionOnWindowScroll">
        </ajaxToolkit:ModalPopupExtender>
        <asp:Panel runat="server" CssClass="modalPopup" ID="programmaticPopup" Style="background-color: ##FFFFCC;
            display: none; height: 125px; width: 225px; padding: 10px">
            content
        </asp:Panel>
        </form>
    </body>
      
        protected void loginButton_Click(object sender, EventArgs e)
        {
            //if( )
            programmaticModalPopup.Show();
        }

     If you want to achieve it asynchronously, you can build an UpdatePanel and set loginButton as Trigger.

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (3 items)