setfocus in web control page

G

Guest

Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does not work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX: 103; LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px; POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName" style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX: 111; LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION: absolute; TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION: absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets the
focus, include a javascript code with it and on the onLoad event fire it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




dale zhang said:
Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does not work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX: 103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px; POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName" style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX: 111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION: absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
G

Guest

Hi,

Thank you for your help. I guess the clientID is txtUserName.

But the element 'body' can not be nested within 'DIV'.

So this does not compile.

Any idea? -Dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets the
focus, include a javascript code with it and on the onLoad event fire it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




dale zhang said:
Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does not work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX: 103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px; POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName" style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX: 111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION: absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

It does compile indeed, as a matter of fact, the only line you have to
include in the code behind (the one which gets compiled) is the Controls.Add

<body> is the tag that start the page, all aspx pages have one, why are you
including it inside a DIV ?
There is only one <body> in your page, just add the onload event to the one
you have.

also the script part can be placed at any place, it's just customary to
place it in the header.



cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


dale zhang said:
Hi,

Thank you for your help. I guess the clientID is txtUserName.

But the element 'body' can not be nested within 'DIV'.

So this does not compile.

Any idea? -Dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets the
focus, include a javascript code with it and on the onLoad event fire it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




dale zhang said:
Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does not
work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX: 103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px;
POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName"
style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label
id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button
id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX: 111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION: absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
G

Guest

Hi,

Sorry, web control page does have <body>, <form1> ...

It is different from other web forms.

that is why i have troubles.

thanks anyway. -dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

It does compile indeed, as a matter of fact, the only line you have to
include in the code behind (the one which gets compiled) is the Controls.Add

<body> is the tag that start the page, all aspx pages have one, why are you
including it inside a DIV ?
There is only one <body> in your page, just add the onload event to the one
you have.

also the script part can be placed at any place, it's just customary to
place it in the header.



cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


dale zhang said:
Hi,

Thank you for your help. I guess the clientID is txtUserName.

But the element 'body' can not be nested within 'DIV'.

So this does not compile.

Any idea? -Dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets the
focus, include a javascript code with it and on the onLoad event fire it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does not
work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX: 103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px;
POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName"
style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label
id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button
id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX: 111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION: absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Dale,

I'm completely lost now, do you have problems or not?

The page will have only one <body >

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



dale zhang said:
Hi,

Sorry, web control page does have <body>, <form1> ...

It is different from other web forms.

that is why i have troubles.

thanks anyway. -dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

It does compile indeed, as a matter of fact, the only line you have to
include in the code behind (the one which gets compiled) is the
Controls.Add

<body> is the tag that start the page, all aspx pages have one, why are
you
including it inside a DIV ?
There is only one <body> in your page, just add the onload event to the
one
you have.

also the script part can be placed at any place, it's just customary to
place it in the header.



cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


dale zhang said:
Hi,

Thank you for your help. I guess the clientID is txtUserName.

But the element 'body' can not be nested within 'DIV'.

So this does not compile.

Any idea? -Dale

:

Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets
the
focus, include a javascript code with it and on the onLoad event fire
it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does
not
work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX:
103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px;
POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName"
style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label
id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox
id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button
id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX:
111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION:
absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 
G

Guest

Hi Ignacio,

i do have problem - can not focus in web control page. the cause is web
control page does not have <body> <form1>.

if you open VS and add a web control, you will not see <body> in the html
version of the page.

thanks. -dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi Dale,

I'm completely lost now, do you have problems or not?

The page will have only one <body >

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



dale zhang said:
Hi,

Sorry, web control page does have <body>, <form1> ...

It is different from other web forms.

that is why i have troubles.

thanks anyway. -dale

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

It does compile indeed, as a matter of fact, the only line you have to
include in the code behind (the one which gets compiled) is the
Controls.Add

<body> is the tag that start the page, all aspx pages have one, why are
you
including it inside a DIV ?
There is only one <body> in your page, just add the onload event to the
one
you have.

also the script part can be placed at any place, it's just customary to
place it in the header.



cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


Hi,

Thank you for your help. I guess the clientID is txtUserName.

But the element 'body' can not be nested within 'DIV'.

So this does not compile.

Any idea? -Dale

:

Hi,

Your code is not well formatted and very difficult to read,
It's very easy, you have to get the clientID of the control to gets
the
focus, include a javascript code with it and on the onLoad event fire
it.

In the aspx page:

<script>
var controlToFocus ='';
function OnLoadHandler()
{
if ( controlToFocus != "" )
document.all[controlToFocus].focus();
}
</script>

<body onload="OnLoadHandler();">


In the code behind:

this.Controls.Add( LiteralControl( "<script>controlToFocus ='" +
theControl.ClientID + " ';</script>" );


Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation




Hi,

I saw the post here about setfocus. But they are for web form.

Web control page HTML does not have form1. the Jscript there does
not
work
here.

My question is how to set focus to the text box in web control page?


The following is the html version of the page design:

<DIV style="WIDTH: 992px; POSITION: relative; HEIGHT: 424px"
ms_positioning="GridLayout"><asp:label id="Label3" style="Z-INDEX:
103;
LEFT:
344px; POSITION: absolute; TOP: 88px" ForeColor="#FF8080"
runat="server">Please login to access private content</asp:label>

<asp:textbox id="txtUserName" style="Z-INDEX: 104; LEFT: 448px;
POSITION:
absolute; TOP: 144px"
runat="server"></asp:textbox><asp:label id="lblUserName"
style="Z-INDEX:
105; LEFT: 280px; POSITION: absolute; TOP: 144px"
runat="server">Enter email address</asp:label><asp:label
id="lblPassword"
style="Z-INDEX: 106; LEFT: 280px; POSITION: absolute; TOP: 192px"
runat="server">Enter password</asp:label><asp:textbox
id="txtPassword"
style="Z-INDEX: 107; LEFT: 448px; POSITION: absolute; TOP: 192px"
runat="server" TextMode="Password"></asp:textbox><asp:button
id="Button1"
style="Z-INDEX: 108; LEFT: 448px; POSITION: absolute; TOP: 240px"
runat="server"
Text="Login"></asp:button>
<asp:regularexpressionvalidator id="revUsername" style="Z-INDEX:
111;
LEFT:
664px; POSITION: absolute; TOP: 144px"
runat="server" Display="Dynamic"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtUserName"
ErrorMessage="Enter the email address as :
(e-mail address removed)">*</asp:regularexpressionvalidator><asp:requiredfieldvalidator
id="rfvUsername" style="Z-INDEX: 112; LEFT: 728px; POSITION:
absolute;
TOP:
144px"
runat="server" Display="Dynamic" ControlToValidate="txtUserName"
ErrorMessage="Enter the correct user
ID"></asp:requiredfieldvalidator><asp:requiredfieldvalidator
id="rfvPassword"
style="Z-INDEX: 113; LEFT: 728px; POSITION: absolute; TOP: 192px"
runat="server" Display="Dynamic" ControlToValidate="txtPassword"
ErrorMessage="Enter the correct
password"></asp:requiredfieldvalidator><asp:validationsummary
id="ValidationSummary1" style="Z-INDEX: 114; LEFT: 440px; POSITION:
absolute;
TOP: 288px"
Width="364px" runat="server" HeaderText="Please correct the
followings:"></asp:validationsummary><asp:label id="lblSuccess"
style="Z-INDEX: 115; LEFT: 544px; POSITION: absolute; TOP: 240px"
runat="server"></asp:label></DIV>

Thanks. -Dale
 

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

Top