setting focus to an asp.net web user control

Discussion in 'ASP .Net' started by =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004.

  1. Hi,

    I'm having problems setting focus to a textbox on a web user contol on an
    asp.net web page. The following script works on normal asp.net pages:

    <script language="javascript">
    function cmdButton1_Clicked()
    { document.all('txtInput1').focus();
    return false;
    }
    </script>

    But it fails when using web user controls. Anyone know how to set focus to
    an object in this senario?
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    Kumar Reddi Guest

    When you usercontrols, the controls inside the userControls will have an id
    like userContrlID:childControlID

    So, lets say your user control has an id like "uc1"
    and the textbox inside it has an id like "txtInput1"

    Then your textbox's id after it is rendered to the web page becomes
    "uc1:txtInput1"

    So you should use

    document.all('uc1:txtInput1').focus();

    Let me know if its not clear. Good Luck
    --
    Kumar Reddi
    http://kumarreddi.blogspot.com

    "CLEAR-RCIC" <> wrote in message
    news:...
    > Hi,
    >
    > I'm having problems setting focus to a textbox on a web user contol on an
    > asp.net web page. The following script works on normal asp.net pages:
    >
    > <script language="javascript">
    > function cmdButton1_Clicked()
    > { document.all('txtInput1').focus();
    > return false;
    > }
    > </script>
    >
    > But it fails when using web user controls. Anyone know how to set focus

    to
    > an object in this senario?
    Kumar Reddi, Dec 6, 2004
    #2
    1. Advertising

  3. That doesn't seem to work either:

    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
    Inherits="FocusTester.WebForm1"%>
    <%@ Register TagPrefix="uc1" TagName="WebUserControl1"
    Src="WebUserControl1.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <script language="javascript">
    var control = document.getElementById("uc1:TextBox2");
    alert(control)
    if( control != null ){control.focus();}
    </script>

    <body>
    <form id="Form1" method="post" runat="server">
    <asp:TextBox id="txtInput1" runat="server"></asp:TextBox>
    <br>
    <uc1:WebUserControl1 id="WebUserControl11"
    runat="server"></uc1:WebUserControl1>
    </form>
    </body>
    </HTML>


    "CLEAR-RCIC" wrote:

    > Hi,
    >
    > I'm having problems setting focus to a textbox on a web user contol on an
    > asp.net web page. The following script works on normal asp.net pages:
    >
    > <script language="javascript">
    > function cmdButton1_Clicked()
    > { document.all('txtInput1').focus();
    > return false;
    > }
    > </script>
    >
    > But it fails when using web user controls. Anyone know how to set focus to
    > an object in this senario?
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #3
  4. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    Kumar Reddi Guest

    Huh!!, your user control id is "WebUserControl11" not uc1, so it should be
    var control = document.getElementById("WebUserControl11:TextBox2");
    --
    Kumar Reddi
    http://kumarreddi.blogspot.com

    "CLEAR-RCIC" <> wrote in message
    news:...
    > That doesn't seem to work either:
    >
    > <%@ Page Language="vb" AutoEventWireup="false"

    Codebehind="WebForm1.aspx.vb"
    > Inherits="FocusTester.WebForm1"%>
    > <%@ Register TagPrefix="uc1" TagName="WebUserControl1"
    > Src="WebUserControl1.ascx" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>WebForm1</title>
    > <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    > <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaultClientScript" content="JavaScript">
    > <meta name="vs_targetSchema"
    > content="http://schemas.microsoft.com/intellisense/ie5">
    > </HEAD>
    > <script language="javascript">
    > var control = document.getElementById("uc1:TextBox2");
    > alert(control)
    > if( control != null ){control.focus();}
    > </script>
    >
    > <body>
    > <form id="Form1" method="post" runat="server">
    > <asp:TextBox id="txtInput1" runat="server"></asp:TextBox>
    > <br>
    > <uc1:WebUserControl1 id="WebUserControl11"
    > runat="server"></uc1:WebUserControl1>
    > </form>
    > </body>
    > </HTML>
    >
    >
    > "CLEAR-RCIC" wrote:
    >
    > > Hi,
    > >
    > > I'm having problems setting focus to a textbox on a web user contol on

    an
    > > asp.net web page. The following script works on normal asp.net pages:
    > >
    > > <script language="javascript">
    > > function cmdButton1_Clicked()
    > > { document.all('txtInput1').focus();
    > > return false;
    > > }
    > > </script>
    > >
    > > But it fails when using web user controls. Anyone know how to set focus

    to
    > > an object in this senario?
    Kumar Reddi, Dec 6, 2004
    #4
  5. I had tried that to. That doesn't work work either.

    "CLEAR-RCIC" wrote:

    > Hi,
    >
    > I'm having problems setting focus to a textbox on a web user contol on an
    > asp.net web page. The following script works on normal asp.net pages:
    >
    > <script language="javascript">
    > function cmdButton1_Clicked()
    > { document.all('txtInput1').focus();
    > return false;
    > }
    > </script>
    >
    > But it fails when using web user controls. Anyone know how to set focus to
    > an object in this senario?
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #5
  6. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    Kumar Reddi Guest

    Well, how about posting the html rendered by the way, that way we can find
    out what the textbox2 is rendering as
    --
    Kumar Reddi
    http://kumarreddi.blogspot.com

    "CLEAR-RCIC" <> wrote in message
    news:...
    > I had tried that to. That doesn't work work either.
    >
    > "CLEAR-RCIC" wrote:
    >
    > > Hi,
    > >
    > > I'm having problems setting focus to a textbox on a web user contol on

    an
    > > asp.net web page. The following script works on normal asp.net pages:
    > >
    > > <script language="javascript">
    > > function cmdButton1_Clicked()
    > > { document.all('txtInput1').focus();
    > > return false;
    > > }
    > > </script>
    > >
    > > But it fails when using web user controls. Anyone know how to set focus

    to
    > > an object in this senario?
    Kumar Reddi, Dec 6, 2004
    #6
  7. Good thinking. Here it is:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <!-- saved from url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    <HTML><HEAD><TITLE>WebForm1</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=utf-8">
    <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    <META content=JavaScript name=vs_defaultClientScript>
    <META content=http://schemas.microsoft.com/intellisense/ie5
    name=vs_targetSchema>
    <SCRIPT language=javascript>
    var control = document.getElementById("WebUserControl11:TextBox2");
    alert(control)
    if( control != null ){control.focus();}
    </SCRIPT>
    </HEAD>
    <BODY>
    <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT type=hidden
    value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA== name=__VIEWSTATE>
    <INPUT
    id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    name=WebUserControl11:TextBox2> </FORM></BODY></HTML>


    "Kumar Reddi" wrote:

    >
    > Well, how about posting the html rendered by the way, that way we can find
    > out what the textbox2 is rendering as
    > --
    > Kumar Reddi
    > http://kumarreddi.blogspot.com
    >
    > "CLEAR-RCIC" <> wrote in message
    > news:...
    > > I had tried that to. That doesn't work work either.
    > >
    > > "CLEAR-RCIC" wrote:
    > >
    > > > Hi,
    > > >
    > > > I'm having problems setting focus to a textbox on a web user contol on

    > an
    > > > asp.net web page. The following script works on normal asp.net pages:
    > > >
    > > > <script language="javascript">
    > > > function cmdButton1_Clicked()
    > > > { document.all('txtInput1').focus();
    > > > return false;
    > > > }
    > > > </script>
    > > >
    > > > But it fails when using web user controls. Anyone know how to set focus

    > to
    > > > an object in this senario?

    >
    >
    >
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #7
  8. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    Kumar Reddi Guest

    Hmm as you can see it rendered as "WebUserControl11_TextBox2 " instead of
    the colon ":". So use the WebUserControl11_TextBox2 to reference it

    --
    Kumar Reddi
    http://kumarreddi.blogspot.com

    "CLEAR-RCIC" <> wrote in message
    news:...
    > Good thinking. Here it is:
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <!-- saved from url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    > <HTML><HEAD><TITLE>WebForm1</TITLE>
    > <META http-equiv=Content-Type content="text/html; charset=utf-8">
    > <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    > <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    > <META content=JavaScript name=vs_defaultClientScript>
    > <META content=http://schemas.microsoft.com/intellisense/ie5
    > name=vs_targetSchema>
    > <SCRIPT language=javascript>
    > var control = document.getElementById("WebUserControl11:TextBox2");
    > alert(control)
    > if( control != null ){control.focus();}
    > </SCRIPT>
    > </HEAD>
    > <BODY>
    > <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT

    type=hidden
    > value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA== name=__VIEWSTATE>
    > <INPUT
    > id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    > name=WebUserControl11:TextBox2> </FORM></BODY></HTML>
    >
    >
    > "Kumar Reddi" wrote:
    >
    > >
    > > Well, how about posting the html rendered by the way, that way we can

    find
    > > out what the textbox2 is rendering as
    > > --
    > > Kumar Reddi
    > > http://kumarreddi.blogspot.com
    > >
    > > "CLEAR-RCIC" <> wrote in message
    > > news:...
    > > > I had tried that to. That doesn't work work either.
    > > >
    > > > "CLEAR-RCIC" wrote:
    > > >
    > > > > Hi,
    > > > >
    > > > > I'm having problems setting focus to a textbox on a web user contol

    on
    > > an
    > > > > asp.net web page. The following script works on normal asp.net

    pages:
    > > > >
    > > > > <script language="javascript">
    > > > > function cmdButton1_Clicked()
    > > > > { document.all('txtInput1').focus();
    > > > > return false;
    > > > > }
    > > > > </script>
    > > > >
    > > > > But it fails when using web user controls. Anyone know how to set

    focus
    > > to
    > > > > an object in this senario?

    > >
    > >
    > >
    Kumar Reddi, Dec 6, 2004
    #8
  9. "Kumar Reddi" wrote:

    > Hmm as you can see it rendered as "WebUserControl11_TextBox2 " instead of
    > the colon ":". So use the WebUserControl11_TextBox2 to reference it
    >
    > --
    > Kumar Reddi
    > http://kumarreddi.blogspot.com
    >
    > "CLEAR-RCIC" <> wrote in message
    > news:...
    > > Good thinking. Here it is:
    > >
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > <!-- saved from url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    > > <HTML><HEAD><TITLE>WebForm1</TITLE>
    > > <META http-equiv=Content-Type content="text/html; charset=utf-8">
    > > <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    > > <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    > > <META content=JavaScript name=vs_defaultClientScript>
    > > <META content=http://schemas.microsoft.com/intellisense/ie5
    > > name=vs_targetSchema>
    > > <SCRIPT language=javascript>
    > > var control = document.getElementById("WebUserControl11:TextBox2");
    > > alert(control)
    > > if( control != null ){control.focus();}
    > > </SCRIPT>
    > > </HEAD>
    > > <BODY>
    > > <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT

    > type=hidden
    > > value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA== name=__VIEWSTATE>
    > > <INPUT
    > > id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    > > name=WebUserControl11:TextBox2> </FORM></BODY></HTML>
    > >
    > >
    > > "Kumar Reddi" wrote:
    > >
    > > >
    > > > Well, how about posting the html rendered by the way, that way we can

    > find
    > > > out what the textbox2 is rendering as
    > > > --
    > > > Kumar Reddi
    > > > http://kumarreddi.blogspot.com
    > > >
    > > > "CLEAR-RCIC" <> wrote in message
    > > > news:...
    > > > > I had tried that to. That doesn't work work either.
    > > > >
    > > > > "CLEAR-RCIC" wrote:
    > > > >
    > > > > > Hi,
    > > > > >
    > > > > > I'm having problems setting focus to a textbox on a web user contol

    > on
    > > > an
    > > > > > asp.net web page. The following script works on normal asp.net

    > pages:
    > > > > >
    > > > > > <script language="javascript">
    > > > > > function cmdButton1_Clicked()
    > > > > > { document.all('txtInput1').focus();
    > > > > > return false;
    > > > > > }
    > > > > > </script>
    > > > > >
    > > > > > But it fails when using web user controls. Anyone know how to set

    > focus
    > > > to
    > > > > > an object in this senario?
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #9
  10. Yep. Tried that too. It doesn't work either. I'm putting this code on the
    main WebForm1.aspx page. That's correct isn't it?

    "Kumar Reddi" wrote:

    > Hmm as you can see it rendered as "WebUserControl11_TextBox2 " instead of
    > the colon ":". So use the WebUserControl11_TextBox2 to reference it
    >
    > --
    > Kumar Reddi
    > http://kumarreddi.blogspot.com
    >
    > "CLEAR-RCIC" <> wrote in message
    > news:...
    > > Good thinking. Here it is:
    > >
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > <!-- saved from url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    > > <HTML><HEAD><TITLE>WebForm1</TITLE>
    > > <META http-equiv=Content-Type content="text/html; charset=utf-8">
    > > <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    > > <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    > > <META content=JavaScript name=vs_defaultClientScript>
    > > <META content=http://schemas.microsoft.com/intellisense/ie5
    > > name=vs_targetSchema>
    > > <SCRIPT language=javascript>
    > > var control = document.getElementById("WebUserControl11:TextBox2");
    > > alert(control)
    > > if( control != null ){control.focus();}
    > > </SCRIPT>
    > > </HEAD>
    > > <BODY>
    > > <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT

    > type=hidden
    > > value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA== name=__VIEWSTATE>
    > > <INPUT
    > > id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    > > name=WebUserControl11:TextBox2> </FORM></BODY></HTML>
    > >
    > >
    > > "Kumar Reddi" wrote:
    > >
    > > >
    > > > Well, how about posting the html rendered by the way, that way we can

    > find
    > > > out what the textbox2 is rendering as
    > > > --
    > > > Kumar Reddi
    > > > http://kumarreddi.blogspot.com
    > > >
    > > > "CLEAR-RCIC" <> wrote in message
    > > > news:...
    > > > > I had tried that to. That doesn't work work either.
    > > > >
    > > > > "CLEAR-RCIC" wrote:
    > > > >
    > > > > > Hi,
    > > > > >
    > > > > > I'm having problems setting focus to a textbox on a web user contol

    > on
    > > > an
    > > > > > asp.net web page. The following script works on normal asp.net

    > pages:
    > > > > >
    > > > > > <script language="javascript">
    > > > > > function cmdButton1_Clicked()
    > > > > > { document.all('txtInput1').focus();
    > > > > > return false;
    > > > > > }
    > > > > > </script>
    > > > > >
    > > > > > But it fails when using web user controls. Anyone know how to set

    > focus
    > > > to
    > > > > > an object in this senario?
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #10
  11. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    Kumar Reddi Guest

    Hmm there the problem is. I thought you had the code executing in response
    to an event. Ok, as you can see the code is in the HEAD section. This code
    executes before, the controls are even written to the page. So, your
    javascript code is not able to find the control you are referring to, since
    its not loaded yet. So,you should put this code after the closing FORM tag
    and inside the closing BODY tag. At this position, the controls on the page
    are loaded, but the form is not shown to the user yet. So, that should do
    your work
    --
    Kumar Reddi
    http://kumarreddi.blogspot.com

    "CLEAR-RCIC" <> wrote in message
    news:...
    > Yep. Tried that too. It doesn't work either. I'm putting this code on

    the
    > main WebForm1.aspx page. That's correct isn't it?
    >
    > "Kumar Reddi" wrote:
    >
    > > Hmm as you can see it rendered as "WebUserControl11_TextBox2 " instead

    of
    > > the colon ":". So use the WebUserControl11_TextBox2 to reference it
    > >
    > > --
    > > Kumar Reddi
    > > http://kumarreddi.blogspot.com
    > >
    > > "CLEAR-RCIC" <> wrote in message
    > > news:...
    > > > Good thinking. Here it is:
    > > >
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > > <!-- saved from

    url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    > > > <HTML><HEAD><TITLE>WebForm1</TITLE>
    > > > <META http-equiv=Content-Type content="text/html; charset=utf-8">
    > > > <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    > > > <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    > > > <META content=JavaScript name=vs_defaultClientScript>
    > > > <META content=http://schemas.microsoft.com/intellisense/ie5
    > > > name=vs_targetSchema>
    > > > <SCRIPT language=javascript>
    > > > var control = document.getElementById("WebUserControl11:TextBox2");
    > > > alert(control)
    > > > if( control != null ){control.focus();}
    > > > </SCRIPT>
    > > > </HEAD>
    > > > <BODY>
    > > > <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT

    > > type=hidden
    > > > value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA==

    name=__VIEWSTATE>
    > > > <INPUT
    > > > id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    > > > name=WebUserControl11:TextBox2> </FORM></BODY></HTML>
    > > >
    > > >
    > > > "Kumar Reddi" wrote:
    > > >
    > > > >
    > > > > Well, how about posting the html rendered by the way, that way we

    can
    > > find
    > > > > out what the textbox2 is rendering as
    > > > > --
    > > > > Kumar Reddi
    > > > > http://kumarreddi.blogspot.com
    > > > >
    > > > > "CLEAR-RCIC" <> wrote in message
    > > > > news:...
    > > > > > I had tried that to. That doesn't work work either.
    > > > > >
    > > > > > "CLEAR-RCIC" wrote:
    > > > > >
    > > > > > > Hi,
    > > > > > >
    > > > > > > I'm having problems setting focus to a textbox on a web user

    contol
    > > on
    > > > > an
    > > > > > > asp.net web page. The following script works on normal asp.net

    > > pages:
    > > > > > >
    > > > > > > <script language="javascript">
    > > > > > > function cmdButton1_Clicked()
    > > > > > > { document.all('txtInput1').focus();
    > > > > > > return false;
    > > > > > > }
    > > > > > > </script>
    > > > > > >
    > > > > > > But it fails when using web user controls. Anyone know how to

    set
    > > focus
    > > > > to
    > > > > > > an object in this senario?
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
    Kumar Reddi, Dec 6, 2004
    #11
  12. Yup. That did it. I know that the code has to go after the contol is
    rendered but had lost track after trying too many different things. Thanks
    for all your help.

    "Kumar Reddi" wrote:

    >
    > Hmm there the problem is. I thought you had the code executing in response
    > to an event. Ok, as you can see the code is in the HEAD section. This code
    > executes before, the controls are even written to the page. So, your
    > javascript code is not able to find the control you are referring to, since
    > its not loaded yet. So,you should put this code after the closing FORM tag
    > and inside the closing BODY tag. At this position, the controls on the page
    > are loaded, but the form is not shown to the user yet. So, that should do
    > your work
    > --
    > Kumar Reddi
    > http://kumarreddi.blogspot.com
    >
    > "CLEAR-RCIC" <> wrote in message
    > news:...
    > > Yep. Tried that too. It doesn't work either. I'm putting this code on

    > the
    > > main WebForm1.aspx page. That's correct isn't it?
    > >
    > > "Kumar Reddi" wrote:
    > >
    > > > Hmm as you can see it rendered as "WebUserControl11_TextBox2 " instead

    > of
    > > > the colon ":". So use the WebUserControl11_TextBox2 to reference it
    > > >
    > > > --
    > > > Kumar Reddi
    > > > http://kumarreddi.blogspot.com
    > > >
    > > > "CLEAR-RCIC" <> wrote in message
    > > > news:...
    > > > > Good thinking. Here it is:
    > > > >
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > > > > <!-- saved from

    > url=(0042)http://localhost/FocusTester/WebForm1.aspx -->
    > > > > <HTML><HEAD><TITLE>WebForm1</TITLE>
    > > > > <META http-equiv=Content-Type content="text/html; charset=utf-8">
    > > > > <META content="MSHTML 6.00.2800.1400" name=GENERATOR>
    > > > > <META content="Visual Basic .NET 7.1" name=CODE_LANGUAGE>
    > > > > <META content=JavaScript name=vs_defaultClientScript>
    > > > > <META content=http://schemas.microsoft.com/intellisense/ie5
    > > > > name=vs_targetSchema>
    > > > > <SCRIPT language=javascript>
    > > > > var control = document.getElementById("WebUserControl11:TextBox2");
    > > > > alert(control)
    > > > > if( control != null ){control.focus();}
    > > > > </SCRIPT>
    > > > > </HEAD>
    > > > > <BODY>
    > > > > <FORM id=Form1 name=Form1 action=WebForm1.aspx method=post><INPUT
    > > > type=hidden
    > > > > value=dDwxNzE0Mjk4ODM7Oz5LkR2Ym7FGguoxTWTE3/K4xV30DA==

    > name=__VIEWSTATE>
    > > > > <INPUT
    > > > > id=txtInput1 name=txtInput1> <BR><INPUT id=WebUserControl11_TextBox2
    > > > > name=WebUserControl11:TextBox2> </FORM></BODY></HTML>
    > > > >
    > > > >
    > > > > "Kumar Reddi" wrote:
    > > > >
    > > > > >
    > > > > > Well, how about posting the html rendered by the way, that way we

    > can
    > > > find
    > > > > > out what the textbox2 is rendering as
    > > > > > --
    > > > > > Kumar Reddi
    > > > > > http://kumarreddi.blogspot.com
    > > > > >
    > > > > > "CLEAR-RCIC" <> wrote in message
    > > > > > news:...
    > > > > > > I had tried that to. That doesn't work work either.
    > > > > > >
    > > > > > > "CLEAR-RCIC" wrote:
    > > > > > >
    > > > > > > > Hi,
    > > > > > > >
    > > > > > > > I'm having problems setting focus to a textbox on a web user

    > contol
    > > > on
    > > > > > an
    > > > > > > > asp.net web page. The following script works on normal asp.net
    > > > pages:
    > > > > > > >
    > > > > > > > <script language="javascript">
    > > > > > > > function cmdButton1_Clicked()
    > > > > > > > { document.all('txtInput1').focus();
    > > > > > > > return false;
    > > > > > > > }
    > > > > > > > </script>
    > > > > > > >
    > > > > > > > But it fails when using web user controls. Anyone know how to

    > set
    > > > focus
    > > > > > to
    > > > > > > > an object in this senario?
    > > > > >
    > > > > >
    > > > > >
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004
    #12
  13. Did it work now?
    Patrick


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Patrick Olurotimi Ige, Dec 7, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB
    Replies:
    0
    Views:
    407
    MattB
    Sep 27, 2005
  2. Jason
    Replies:
    4
    Views:
    1,616
    Jason
    May 7, 2007
  3. Colin Halliday

    Setting Focus in Web User Control that Uses AJAX Update Panel

    Colin Halliday, Apr 24, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    192
    Colin Halliday
    Apr 24, 2007
  4. Jesper Dannemamm

    HELP: setting focus asp:textbox in a user control

    Jesper Dannemamm, Dec 6, 2003, in forum: ASP General
    Replies:
    3
    Views:
    214
    Aaron Bertrand [MVP]
    Dec 6, 2003
  5. Roger
    Replies:
    3
    Views:
    320
Loading...

Share This Page