aspx HTML Server Control Question

G

Guest

Hi there

I am trying to introduce some dynamic control focus in to my asp application
by turning the <body> of the aspx file in to an HTML Server control.

I have read elsewhere that if you assign an ID to the <body> as well as
runat="server" : e.g.

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

you should then be able to use:

PageBody.Attributes("onload") = "document.forms[0] ['TextBox'].focus();"

for example to shift focus on to certain controls when you want...

All good

My problem is that when you assign an ID and runat="server" to the <body> it
is not automatically declared in the aspx.vb file as you would normally get
if you simply drag an asp control on to the designer page. Obviously I am
guilty of relying on the automation normally - but how do I declare PageBody
in the aspx.vb... what do I declare it as ???

Your help is much appreciated
 
K

Kevin Spencer

Here's a little trick for you: You don't need to use the body onload
attribute to have a script run when the page loads. Just put the script into
the body of the page, not as a function, but as script. It will run when the
page loads. That is exactly what Page.RegisterStartupScript() does.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

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,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top