By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

setting focus in ASP 1.1, despite of smartnavigation

P: n/a
Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons on the
form. One that takes action on the entered information and one that resets
the form...

The second on, the reset button, i would like to set focus back to the first
textbox on the form. I already have an onload in my body, which sets the
focus on the initial load, but this does not repeat this functionallity on
the postback reload. I use smartnavigation, so that only the necesarry
renewale is done.

How can i implement the setfocus to my textbox??

/Finn
Feb 12 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
One way, may be not optimal but straightforward, is to introduce a hidden
input control and set it on server side to the client id of the control that
is supposed to get focus. Then, in the body's online event get the id, find
the control and call it's focus() method.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Finn Stampe Mikkelsen" <st****@city.dkwrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons on
the form. One that takes action on the entered information and one that
resets the form...

The second on, the reset button, i would like to set focus back to the
first textbox on the form. I already have an onload in my body, which sets
the focus on the initial load, but this does not repeat this
functionallity on the postback reload. I use smartnavigation, so that only
the necesarry renewale is done.

How can i implement the setfocus to my textbox??

/Finn

Feb 12 '07 #2

P: n/a
Hi Eliyahu

Yeah, well... Seems like one way of solving the problem... But...

Using the SmartNavigation, ensuring that the page looks efficient upon
resetting the form, the body's OnLoad event is not fired upon PostBack
reload of the page. I have, as is, an OnLoad event setting the focus to my
initial Form textBox. It is actually the same box which should refocus after
emptying the forms content. this however is not solved with the onload event
and it seems that your proposal would do the same thing...

Will try it at postback the result...

/Finn

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgskrev i en
meddelelse news:u6**************@TK2MSFTNGP05.phx.gbl...
One way, may be not optimal but straightforward, is to introduce a hidden
input control and set it on server side to the client id of the control
that is supposed to get focus. Then, in the body's online event get the
id, find the control and call it's focus() method.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Finn Stampe Mikkelsen" <st****@city.dkwrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
>Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons on
the form. One that takes action on the entered information and one that
resets the form...

The second on, the reset button, i would like to set focus back to the
first textbox on the form. I already have an onload in my body, which
sets the focus on the initial load, but this does not repeat this
functionallity on the postback reload. I use smartnavigation, so that
only the necesarry renewale is done.

How can i implement the setfocus to my textbox??

/Finn




Feb 12 '07 #3

P: n/a
the onload fires with smart nav, but the postback page is rendered in a
hidden frame, you need to set the focus in the parent. but the be
careful, becuase the parent page is attached to the onload, rebuilds
itself coping the nodes from the child, so you need to use a
window.setTimeout so you code runs after the smartnav code.

-- bruce (sqlwork.com)

Finn Stampe Mikkelsen wrote:
Hi Eliyahu

Yeah, well... Seems like one way of solving the problem... But...

Using the SmartNavigation, ensuring that the page looks efficient upon
resetting the form, the body's OnLoad event is not fired upon PostBack
reload of the page. I have, as is, an OnLoad event setting the focus to my
initial Form textBox. It is actually the same box which should refocus after
emptying the forms content. this however is not solved with the onload event
and it seems that your proposal would do the same thing...

Will try it at postback the result...

/Finn

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgskrev i en
meddelelse news:u6**************@TK2MSFTNGP05.phx.gbl...
>One way, may be not optimal but straightforward, is to introduce a hidden
input control and set it on server side to the client id of the control
that is supposed to get focus. Then, in the body's online event get the
id, find the control and call it's focus() method.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Finn Stampe Mikkelsen" <st****@city.dkwrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
>>Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons on
the form. One that takes action on the entered information and one that
resets the form...

The second on, the reset button, i would like to set focus back to the
first textbox on the form. I already have an onload in my body, which
sets the focus on the initial load, but this does not repeat this
functionallity on the postback reload. I use smartnavigation, so that
only the necesarry renewale is done.

How can i implement the setfocus to my textbox??

/Finn



Feb 12 '07 #4

P: n/a
, that the onload event did'nt
fire. I also had a hard time to understand, why i could use a
Page.RegisterStartupScript and have an Alert box pop up, but i could not use
the same to set the focus to an object, although both were set at postback
time on a Smartnav page..

Could you elaborate what you mean. maybe an example code snipplet??

/Finn

"bruce barker" <no****@nospam.comskrev i en meddelelse
news:%2****************@TK2MSFTNGP04.phx.gbl...
the onload fires with smart nav, but the postback page is rendered in a
hidden frame, you need to set the focus in the parent. but the be careful,
becuase the parent page is attached to the onload, rebuilds itself coping
the nodes from the child, so you need to use a window.setTimeout so you
code runs after the smartnav code.

-- bruce (sqlwork.com)

Finn Stampe Mikkelsen wrote:
>Hi Eliyahu

Yeah, well... Seems like one way of solving the problem... But...

Using the SmartNavigation, ensuring that the page looks efficient upon
resetting the form, the body's OnLoad event is not fired upon PostBack
reload of the page. I have, as is, an OnLoad event setting the focus to
my initial Form textBox. It is actually the same box which should refocus
after emptying the forms content. this however is not solved with the
onload event and it seems that your proposal would do the same thing...

Will try it at postback the result...

/Finn

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgskrev i en
meddelelse news:u6**************@TK2MSFTNGP05.phx.gbl...
>>One way, may be not optimal but straightforward, is to introduce a
hidden input control and set it on server side to the client id of the
control that is supposed to get focus. Then, in the body's online event
get the id, find the control and call it's focus() method.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Finn Stampe Mikkelsen" <st****@city.dkwrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons
on the form. One that takes action on the entered information and one
that resets the form...

The second on, the reset button, i would like to set focus back to the
first textbox on the form. I already have an onload in my body, which
sets the focus on the initial load, but this does not repeat this
functionallity on the postback reload. I use smartnavigation, so that
only the necesarry renewale is done.

How can i implement the setfocus to my textbox??

/Finn



Feb 12 '07 #5

P: n/a


Hi bruce

This goes beyond my capabillities. I was sure, that the onload event did'nt
fire. I also had a hard time to understand, why i could use a
Page.RegisterStartupScript and have an Alert box pop up, but i could not use
the same to set the focus to an object, although both were set at postback
time on a Smartnav page..

Could you elaborate what you mean. maybe an example code snipplet??

/Finn

"bruce barker" <no****@nospam.comskrev i en meddelelse
news:%2****************@TK2MSFTNGP04.phx.gbl...
the onload fires with smart nav, but the postback page is rendered in a
hidden frame, you need to set the focus in the parent. but the be careful,
becuase the parent page is attached to the onload, rebuilds itself coping
the nodes from the child, so you need to use a window.setTimeout so you
code runs after the smartnav code.

-- bruce (sqlwork.com)

Finn Stampe Mikkelsen wrote:
>Hi Eliyahu

Yeah, well... Seems like one way of solving the problem... But...

Using the SmartNavigation, ensuring that the page looks efficient upon
resetting the form, the body's OnLoad event is not fired upon PostBack
reload of the page. I have, as is, an OnLoad event setting the focus to
my initial Form textBox. It is actually the same box which should refocus
after emptying the forms content. this however is not solved with the
onload event and it seems that your proposal would do the same thing...

Will try it at postback the result...

/Finn

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgskrev i en
meddelelse news:u6**************@TK2MSFTNGP05.phx.gbl...
>>One way, may be not optimal but straightforward, is to introduce a
hidden input control and set it on server side to the client id of the
control that is supposed to get focus. Then, in the body's online event
get the id, find the control and call it's focus() method.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Finn Stampe Mikkelsen" <st****@city.dkwrote in message
news:OS**************@TK2MSFTNGP03.phx.gbl...
Hi

How can i set a focus to a textbox in my codebehind page??

I have this WebForm, that takes information from a user and 2 buttons
on the form. One that takes action on the entered information and one
that resets the form...

The second on, the reset button, i would like to set focus back to the
first textbox on the form. I already have an onload in my body, which
sets the focus on the initial load, but this does not repeat this
functionallity on the postback reload. I use smartnavigation, so that
only the necesarry renewale is done.

How can i implement the setfocus to my textbox??

/Finn



Feb 12 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.