How to set focus in ModalPopUpExtender

Last post 04-23-2009 7:24 PM by cesarinleyva. 8 replies.

Sort Posts:

  • How to set focus in ModalPopUpExtender

    02-11-2008, 5:46 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    helo

    I m using Modal Pop Up Extender...

    i have some controls in modalpopupextender.Now i want to set focus on the textbox of the modalpopupextender when it renders.

    i called

    ModalPopUpExtender.Show();

    now after it is visible i want to set focs on the textbax control located in the modalpopupextender

    sam

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: How to set focus in ModalPopUpExtender

    02-11-2008, 9:35 AM
    • Member
      58 point Member
    • pessi
    • Member since 02-19-2007, 12:52 PM
    • Serskamp, Belgium
    • Posts 104

    hi

     your issue is addressed here.

     
    http://www.aspdotnetcodes.com/ModalPopup_Postback.aspx

     Hope it helps.

    prasad.

     

  • Re: How to set focus in ModalPopUpExtender

    02-15-2008, 4:14 AM
    Answer

    Hi Sam,

    Please add a handler to the ModalPopupExtender's add_shown event hook.  It will be fired when the ModalPanelExtender is shown

          <script type="text/javascript" language="javascript">
                function pageLoad(){
                    $find("ModalPopupExtender's BehavoirID").add_shown(onModalPopupShown);
                }
                function onModalPopupShown(){
                 //set focus here.
                 }

            </script>

    Best regards,

    Jonathan

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to set focus in ModalPopUpExtender

    02-15-2008, 4:59 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    thanks jonathan

    but i want lil detail ov it.

    my first question is u want me to add this code in my .aspx page

    and to call this code i m writing in my .cs class

    Button.Attributes.Add("Click","pageLoad");

    this will call the funtion we wrote in .aspx page

    is that all fine

    sam

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: How to set focus in ModalPopUpExtender

    02-15-2008, 5:09 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    it is working for me

    thnak u very very very very much

    i m really grateful to u for this help

    a great work from a great developer jonathan

    thnks

    sam

     

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: How to set focus in ModalPopUpExtender

    02-15-2008, 5:12 AM

    Hi Sam,

    Sam.Dev:
    my first question is u want me to add this code in my .aspx page

    It is a Javascript code with <script type="text/javascript"> tag.  Here is the working sample. 

    <%@ Page Language="VB" enableEventValidation="false" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
        <style>
         .modalBackground {
    	        background-color:Gray;
    	        filter:alpha(opacity=70);
    	        opacity:0.7;
            }
            .modalPopup {
    	        background-color:#FFD9D5;
    	        border-width:3px;
    	        border-style:solid;
    	        border-color:Gray;
    	        padding:3px;
    	        width:250px;
            }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="200px" Width="300px" Style="display: none;z-index:10000000000" >
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:Button ID="btnClose" runat="server" Text="close" />
            </asp:Panel>
            <asp:Button ID="btnTrigger" runat="server" Text="Button" />
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="myMPEBID" runat="server" TargetControlID="btnTrigger"
                PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="btnClose">
            </ajaxToolkit:ModalPopupExtender>
            <script type="text/javascript">
                function pageLoad(){
                    $find("myMPEBID").add_shown(onModalPopupShown);
                }
                function onModalPopupShown(){
                    $get("<%=TextBox1.ClientID%>").focus();
                }
            </script>
        </form>
    </body>
    </html>
    

     Best regards,

    Jonathan

     

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to set focus in ModalPopUpExtender

    02-15-2008, 5:16 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    thank u so much for ur help

    i highly appreciated

    sam

    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: How to set focus in ModalPopUpExtender

    02-19-2008, 1:22 AM
    • Participant
      1,390 point Participant
    • Sam.Dev
    • Member since 12-12-2006, 10:54 AM
    • Lahore,Pakistan
    • Posts 342

    Here is the code to set focus on server side ScriptManager.GetCurrent(this.Page).SetFocus((Button)UtilityClass.Instance.FindControl("buttonK", this.Page));
    Saima Ghumman
    --Mark the post as Answer if the Post helps you--
  • Re: How to set focus in ModalPopUpExtender

    04-23-2009, 7:24 PM
    • Member
      12 point Member
    • cesarinleyva
    • Member since 09-14-2006, 7:46 PM
    • Posts 4

    Thanks a lot for all your posts, it helped me a lot. Both client Side code and also the last post from the Server side.

     

     

     

     

Page 1 of 1 (9 items)