Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
All-Star
32101 Points
3764 Posts
May 22, 2007 02:15 AM|LINK
Hi,
Basically, I'm agree with Zhou's idea. Just need to make a few changes. See the demo bellow:
[Master]
<%@ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html>
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Button ID="Button1" runat="server" Text="Popup via client" /> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> This is popup control<asp:Login ID="Login1" runat="server"> </asp:Login> <br /> <input id="Button2" type="button" value="button" /> <input id="Button4" type="button" value="button" /></asp:Panel> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" OkControlID="Button2" PopupControlID="Panel1" runat="server" TargetControlID="Button1"> </ajaxToolkit:ModalPopupExtender> </asp:Content>
[CodeBehind]
Partial Class Default2 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then If (Not Me.ClientScript.IsStartupScriptRegistered("Startup")) Then Dim scriptString = "<script type='text/javascript'>" _ & "Sys.Application.add_load(modalSetup);" _ & "function SetFocusOnControl() {" _ & "$get('" _ & Login1.ClientID _ & "_UserName').focus(); }" _ & "function modalSetup() {" _ & "var modalPopup = $find('" _ & ModalPopupExtender1.ClientID _ & "');" _ & "modalPopup.add_shown(SetFocusOnControl); }" _ & "</script>" Me.ClientScript.RegisterStartupScript(Me.GetType(), "Startup", scriptString) End If End If End SubEnd Class
Raymond Wen ...
All-Star
32101 Points
3764 Posts
Re: Set Focus on Textbox in modalPopup Panel
May 22, 2007 02:15 AM|LINK
Hi,
Basically, I'm agree with Zhou's idea. Just need to make a few changes. See the demo bellow:
[Master]
<%@ Master Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </div> </form> </body> </html>[Page][CodeBehind]
Hope this helps