Controls accessing outside tags

T

tshad

I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I have
all my Body tags set to this.

I just tried to strip out the main part of the page and make it a control
(to allow different looks and feels). I have the following statement in the
control:

myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:

**************************************************
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'myBody' is not declared.

Source Error:

Line 9: dim IsCheckResumes as Boolean = true
Line 10: if not IsPostBack
Line 11:
myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
Line 12: end if
Line 13: End Sub
*****************************************************

How can I get this control to be able to access an outside tag?

All my pages that use this control would always have the tag set up this
way.

The aspx file is:
**************************************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >
<form id="addForm" runat="server">
<fts:Logon runat="Server"/>
</form>
</html>
**************************************************************

The ascx file is:
**************************************************************
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="MyFunctions" %>
<%@ Import Namespace="RolesBasedAuthentication" %>
<script runat="server" >
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")
end if
End Sub

</script>

<asp:textbox id="UserName" TextMode="SingleLine" Columns="25" runat="server"
/>
<asp:RequiredFieldValidator
ControlToValidate="UserName"
Text="User Name Required"
runat="server" />
**************************************************************

Thanks,

Tom
 
B

bruce barker

this feature is builtin, the form has a DefaultFocus property.

-- bruce (sqlwork.com)
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

tshad said:
I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I have
all my Body tags set to this.

I just tried to strip out the main part of the page and make it a control
(to allow different looks and feels). I have the following statement in the
control:

myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:
Compiler Error Message: BC30451: Name 'myBody' is not declared.
How can I get this control to be able to access an outside tag?

Make a public property in the page that exposes the body control or an
attribute in the body control.

From the controls you can cast the Page property to the actual class of
the page, so that you can access the property.
 
T

tshad

Göran Andersson said:
tshad said:
I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I
have all my Body tags set to this.

I just tried to strip out the main part of the page and make it a control
(to allow different looks and feels). I have the following statement in
the control:


myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:
Compiler Error Message: BC30451: Name 'myBody' is not declared.
How can I get this control to be able to access an outside tag?

Make a public property in the page that exposes the body control or an
attribute in the body control.

From the controls you can cast the Page property to the actual class of
the page, so that you can access the property.

How would I do that in my example?

Would this apply also to aspx controls (labels or Textbox, for example)?

If I changed the .aspx page to have an aspx label outside of the Form tag
and a texbox inside the Form tag, would I be able to access these from
inside the control?:

For example, if the new aspx file is:
**************************************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >

<asp:Label ID="GenericMessage" runat="server"/>

<form id="addForm" runat="server">

<asp:TextBox ID="UserName" runat="server"/>

<fts:Logon runat="Server"/>
</form>
</html>
**************************************************************

Thanks,

Tom
 
T

tshad

I almost got this to work.

I can now access the <body ID="myBody" runat="server"> tag. When I add the
onLoad event to the myBody tag - it is there, but the control still doesn't
get focus. I named the User Control to make sure I can get to it, but it
still doesn't work.

Here are the 2 files:

test.aspx:
**********************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >
<form id="addForm" runat="server">
<fts:Logon ID="LoginID" runat="Server"/>
</form>
</body>
</html>
***********************************************

test.ascx:
***********************************************
<script runat="server" >
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)
a.Attributes.Add("onLoad","document.forms[0].LoginID.UserName.focus()")
end if
End Sub

Public Property UserName AS String
Get
Return txtUserName.Text
End Get
Set
txtUserName.Text = Value
End Set
End Property

</script>

<asp:textbox id="txtUserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtUserName"
Text="User Name Required"
runat="server" />
**********************************************

I am getting an error that says:

Error: "document.forms.0.LoginID.UserName" is null or not an object

I am confused here. Isn't LoginID part of forms[0]? And isn't UserName part
of LoginID???? Or is it how I am accessing it?

I also tried to changed the Forms ID to "addForm" in the Attributes line to:

a.Attributes.Add("onLoad","document.addForm.LoginID.UserName.focus()")

and get the same error except the forms.0 is replaced with addform.

Here is the Tree from the Trace:

__PAGE ASP.test_aspx
_ctl0 System.Web.UI.LiteralControl
_ctl1 System.Web.UI.LiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl2 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl3 System.Web.UI.LiteralControl
LoginID ASP.test_ascx
LoginID:txtUserName System.Web.UI.WebControls.TextBox
LoginID:_ctl1 System.Web.UI.LiteralControl
LoginID:_ctl0
System.Web.UI.WebControls.RequiredFieldValidator
LoginID:_ctl2 System.Web.UI.LiteralControl
_ctl4 System.Web.UI.LiteralControl
_ctl5 System.Web.UI.LiteralControl
_ctl6 System.Web.UI.LiteralControl

Thanks,

Tom

tshad said:
Göran Andersson said:
tshad said:
I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I
have all my Body tags set to this.

I just tried to strip out the main part of the page and make it a
control (to allow different looks and feels). I have the following
statement in the control:


myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:
Compiler Error Message: BC30451: Name 'myBody' is not declared.
How can I get this control to be able to access an outside tag?

Make a public property in the page that exposes the body control or an
attribute in the body control.

From the controls you can cast the Page property to the actual class of
the page, so that you can access the property.

How would I do that in my example?

Would this apply also to aspx controls (labels or Textbox, for example)?

If I changed the .aspx page to have an aspx label outside of the Form tag
and a texbox inside the Form tag, would I be able to access these from
inside the control?:

For example, if the new aspx file is:
**************************************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >

<asp:Label ID="GenericMessage" runat="server"/>

<form id="addForm" runat="server">

<asp:TextBox ID="UserName" runat="server"/>

<fts:Logon runat="Server"/>
</form>
</html>
**************************************************************

Thanks,

Tom
 
T

tshad

I tried looped through the Form elements and found that the name of the
textbox is actually - LoginID:txtUserName. I change the attribute lines to:

Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)
a.Attributes.Add("onLoad","onload=document.addForm.LoginID:txtUserName.focus();")

I am not getting there error now, but I am also not getting focus.

What is missing here?

Thanks,

Tom

tshad said:
I almost got this to work.

I can now access the <body ID="myBody" runat="server"> tag. When I add
the onLoad event to the myBody tag - it is there, but the control still
doesn't get focus. I named the User Control to make sure I can get to it,
but it still doesn't work.

Here are the 2 files:

test.aspx:
**********************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >
<form id="addForm" runat="server">
<fts:Logon ID="LoginID" runat="Server"/>
</form>
</body>
</html>
***********************************************

test.ascx:
***********************************************
<script runat="server" >
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)
a.Attributes.Add("onLoad","document.forms[0].LoginID.UserName.focus()")
end if
End Sub

Public Property UserName AS String
Get
Return txtUserName.Text
End Get
Set
txtUserName.Text = Value
End Set
End Property

</script>

<asp:textbox id="txtUserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtUserName"
Text="User Name Required"
runat="server" />
**********************************************

I am getting an error that says:

Error: "document.forms.0.LoginID.UserName" is null or not an object

I am confused here. Isn't LoginID part of forms[0]? And isn't UserName
part of LoginID???? Or is it how I am accessing it?

I also tried to changed the Forms ID to "addForm" in the Attributes line
to:

a.Attributes.Add("onLoad","document.addForm.LoginID.UserName.focus()")

and get the same error except the forms.0 is replaced with addform.

Here is the Tree from the Trace:

__PAGE ASP.test_aspx
_ctl0 System.Web.UI.LiteralControl
_ctl1 System.Web.UI.LiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl2 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl3 System.Web.UI.LiteralControl
LoginID ASP.test_ascx
LoginID:txtUserName System.Web.UI.WebControls.TextBox
LoginID:_ctl1 System.Web.UI.LiteralControl
LoginID:_ctl0
System.Web.UI.WebControls.RequiredFieldValidator
LoginID:_ctl2 System.Web.UI.LiteralControl
_ctl4 System.Web.UI.LiteralControl
_ctl5 System.Web.UI.LiteralControl
_ctl6 System.Web.UI.LiteralControl

Thanks,

Tom

tshad said:
Göran Andersson said:
tshad wrote:
I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I
have all my Body tags set to this.

I just tried to strip out the main part of the page and make it a
control (to allow different looks and feels). I have the following
statement in the control:


myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:



Compiler Error Message: BC30451: Name 'myBody' is not declared.



How can I get this control to be able to access an outside tag?


Make a public property in the page that exposes the body control or an
attribute in the body control.

From the controls you can cast the Page property to the actual class of
the page, so that you can access the property.

How would I do that in my example?

Would this apply also to aspx controls (labels or Textbox, for example)?

If I changed the .aspx page to have an aspx label outside of the Form tag
and a texbox inside the Form tag, would I be able to access these from
inside the control?:

For example, if the new aspx file is:
**************************************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >

<asp:Label ID="GenericMessage" runat="server"/>

<form id="addForm" runat="server">

<asp:TextBox ID="UserName" runat="server"/>

<fts:Logon runat="Server"/>
</form>
</html>
**************************************************************

Thanks,

Tom
 
T

tshad

Ok, I got it to work. But not the way I wanted.

As well as the one below I tried:

a.Attributes.Add("onLoad","onload=addForm.LoginID:txtUserName.focus();")

and

a.Attributes.Add("onLoad","onload=LoginID:txtUserName.focus();")

Neither one of these worked. There was no error but there was no focus,
either.

I made a change by calling a Javascript function from the onload function
and this worked. The LoginID:txtUserName is the correct name but why does
the above not work???

The files that work are:

test.aspx:
*************************************************
<%@ Page Language="VB" trace="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<script runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
if not IsPostBack
Dim a as htmlControl
a = CType(Page.FindControl("addForm"),htmlControl)
For each frmCtrl as Control in a.Controls
trace.warn("frmCtrl = " & frmCtrl.GetType.ToString())
trace.warn("frmCtrl.ID = " & frmCtrl.ID)
Next
end if
end sub
</script>
<html>
<head>
<title>Login</title>
<script language="JavaScript">
function GetFocus()
{
if (document.getElementById("LoginID:txtUserName") != null)
{
document.getElementById("LoginID:txtUserName").focus();
}
}
</script>
</head>
<body id="myBody" runat="server">
<form id="addForm" runat="server">
<fts:Logon ID="LoginID" runat="Server"/>
</form>
</body>
</html>
*************************************************

test.ascx:
*************************************************
<script language="vb" runat="server" >
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)
a.Attributes.Add("onLoad","onload=GetFocus();")
end if
End Sub

Public Property UserName AS String
Get
Return txtUserName.Text
End Get
Set
txtUserName.Text = Value
End Set
End Property

</script>

<asp:textbox id="txtUserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtUserName"
Text="User Name Required"
runat="server" />
*************************************************

This works but I would rather do the focus directly from the <body> tag and
not have to build an extra function for each page that needs to have focus.

Can anyone explain to me why this isn't working? Does it have to do with
timing on when a control is put on the page? I would assume this wouldn't
be the case as the page is built before the onload function is called (isn't
it?).

Thanks,

Tom

tshad said:
I tried looped through the Form elements and found that the name of the
textbox is actually - LoginID:txtUserName. I change the attribute lines
to:

Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)

a.Attributes.Add("onLoad","onload=document.addForm.LoginID:txtUserName.focus();")

I am not getting there error now, but I am also not getting focus.

What is missing here?

Thanks,

Tom

tshad said:
I almost got this to work.

I can now access the <body ID="myBody" runat="server"> tag. When I add
the onLoad event to the myBody tag - it is there, but the control still
doesn't get focus. I named the User Control to make sure I can get to
it, but it still doesn't work.

Here are the 2 files:

test.aspx:
**********************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >
<form id="addForm" runat="server">
<fts:Logon ID="LoginID" runat="Server"/>
</form>
</body>
</html>
***********************************************

test.ascx:
***********************************************
<script runat="server" >
Sub Page_Load(sender as Object, e as EventArgs)
dim IsCheckResumes as Boolean = true
if not IsPostBack
Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)

a.Attributes.Add("onLoad","document.forms[0].LoginID.UserName.focus()")
end if
End Sub

Public Property UserName AS String
Get
Return txtUserName.Text
End Get
Set
txtUserName.Text = Value
End Set
End Property

</script>

<asp:textbox id="txtUserName" TextMode="SingleLine" Columns="25"
runat="server" />
<asp:RequiredFieldValidator
ControlToValidate="txtUserName"
Text="User Name Required"
runat="server" />
**********************************************

I am getting an error that says:

Error: "document.forms.0.LoginID.UserName" is null or not an object

I am confused here. Isn't LoginID part of forms[0]? And isn't UserName
part of LoginID???? Or is it how I am accessing it?

I also tried to changed the Forms ID to "addForm" in the Attributes line
to:

a.Attributes.Add("onLoad","document.addForm.LoginID.UserName.focus()")

and get the same error except the forms.0 is replaced with addform.

Here is the Tree from the Trace:

__PAGE ASP.test_aspx
_ctl0 System.Web.UI.LiteralControl
_ctl1 System.Web.UI.LiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl2 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl3 System.Web.UI.LiteralControl
LoginID ASP.test_ascx
LoginID:txtUserName System.Web.UI.WebControls.TextBox
LoginID:_ctl1 System.Web.UI.LiteralControl
LoginID:_ctl0
System.Web.UI.WebControls.RequiredFieldValidator
LoginID:_ctl2 System.Web.UI.LiteralControl
_ctl4 System.Web.UI.LiteralControl
_ctl5 System.Web.UI.LiteralControl
_ctl6 System.Web.UI.LiteralControl

Thanks,

Tom

tshad said:
tshad wrote:
I have a page where I have the Body tag set up as:

<body id="myBody" runat="server" >

This allows me to set the focus to different attributes on my page. I
have all my Body tags set to this.

I just tried to strip out the main part of the page and make it a
control (to allow different looks and feels). I have the following
statement in the control:


myBody.Attributes.Add("onLoad","document.forms[0].UserName.focus()")

And I get the error:



Compiler Error Message: BC30451: Name 'myBody' is not declared.



How can I get this control to be able to access an outside tag?


Make a public property in the page that exposes the body control or an
attribute in the body control.

From the controls you can cast the Page property to the actual class of
the page, so that you can access the property.

How would I do that in my example?

Would this apply also to aspx controls (labels or Textbox, for example)?

If I changed the .aspx page to have an aspx label outside of the Form
tag and a texbox inside the Form tag, would I be able to access these
from inside the control?:

For example, if the new aspx file is:
**************************************************************
<%@ Page Language="VB" trace="false" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ Register TagPrefix="fts" TagName="Logon" Src="test.ascx" %>
<html>
<head>
<title>Login</title>
</head>
<body id="myBody" runat="server" >

<asp:Label ID="GenericMessage" runat="server"/>

<form id="addForm" runat="server">

<asp:TextBox ID="UserName" runat="server"/>

<fts:Logon runat="Server"/>
</form>
</html>
**************************************************************

Thanks,

Tom
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

tshad said:
How would I do that in my example?

Would this apply also to aspx controls (labels or Textbox, for example)?

As the references to the controls are declared as protected by default,
you can't reach them from the user control. You either have to change
the declaration to public or make a public property to expose them.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

tshad said:
I tried looped through the Form elements and found that the name of the
textbox is actually - LoginID:txtUserName.

That's odd. That name is not very usable. I would expect the name to be
LoginID$txtUserName and the id to be LoginID_txtUserName. That's how
controls are usually named.

What does the generated html code for the form look like?
I change the attribute lines to:

Dim a as htmlControl
a = CType(Page.FindControl("myBody"),htmlControl)
a.Attributes.Add("onLoad","onload=document.addForm.LoginID:txtUserName.focus();")

An identifier in Javascript can not contain a colon. If the name really
contains a colon, you would need to use a string to reference it:

onload=document.addForm.elements('LoginID:txtUserName').focus();
I am not getting there error now, but I am also not getting focus.

The browser doesn't display Javscript errors by default. In Internet
Explorer they show up as a notice in the status bar. In Firefox you open
the Error Console to see them.
 
T

tshad

Göran Andersson said:
That's odd. That name is not very usable. I would expect the name to be
LoginID$txtUserName and the id to be LoginID_txtUserName. That's how
controls are usually named.

What does the generated html code for the form look like?

Here is the line with the input tag:

<input name="LoginID:txtUserName" type="text" size="25"
id="LoginID_txtUserName" />
<span id="LoginID__ctl0" controltovalidate="LoginID_txtUserName"
evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue=""
style="color:Red;visibility:hidden;">User Name Required</span>

What is interesting is that the javascript uses the LoginID:txtUserName and
the ID uses the underscore. The trace shows the ":" which is the Name not
the ID.

__PAGE ASP.test_aspx
_ctl0 System.Web.UI.LiteralControl
_ctl1 System.Web.UI.ResourceBasedLiteralControl
myBody System.Web.UI.HtmlControls.HtmlGenericControl
_ctl2 System.Web.UI.LiteralControl
addForm System.Web.UI.HtmlControls.HtmlForm
_ctl3 System.Web.UI.LiteralControl
LoginID ASP.test_ascx
LoginID:_ctl1 System.Web.UI.LiteralControl
LoginID:txtUserName System.Web.UI.WebControls.TextBox
LoginID:_ctl2 System.Web.UI.LiteralControl
LoginID:_ctl0
System.Web.UI.WebControls.RequiredFieldValidator
LoginID:_ctl3 System.Web.UI.LiteralControl
_ctl4 System.Web.UI.LiteralControl
_ctl5 System.Web.UI.LiteralControl
_ctl6 System.Web.UI.LiteralControl

The code that works uses the ":" in the function just not in the inline code
as shown here:

function GetFocus()
{
if (document.getElementById("LoginID:txtUserName") != null)
{
document.getElementById("LoginID:txtUserName").focus();
}
}

Thanks,

Tom
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top