setting focus in ASP 1.1, despite of smartnavigation | | |
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 | | | | re: setting focus in ASP 1.1, despite of smartnavigation
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" <stampe@city.dkwrote in message
news:OSgSEMpTHHA.1036@TK2MSFTNGP03.phx.gbl... Quote:
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
>
| | | | re: setting focus in ASP 1.1, despite of smartnavigation
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" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgskrev i en
meddelelse news:u6FStEqTHHA.3500@TK2MSFTNGP05.phx.gbl... Quote:
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" <stampe@city.dkwrote in message
news:OSgSEMpTHHA.1036@TK2MSFTNGP03.phx.gbl... Quote:
>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
>>
>
>
>
| | | | re: setting focus in ASP 1.1, despite of smartnavigation
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: Quote:
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" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgskrev i en
meddelelse news:u6FStEqTHHA.3500@TK2MSFTNGP05.phx.gbl... Quote:
>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" <stampe@city.dkwrote in message
>news:OSgSEMpTHHA.1036@TK2MSFTNGP03.phx.gbl... Quote:
>>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
>>>
>>
>>
>
>
>
| | | | re: setting focus in ASP 1.1, despite of smartnavigation
, 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" <nospam@nospam.comskrev i en meddelelse
news:%23t8ODRsTHHA.1200@TK2MSFTNGP04.phx.gbl... Quote:
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: Quote:
>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" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgskrev i en
>meddelelse news:u6FStEqTHHA.3500@TK2MSFTNGP05.phx.gbl... Quote:
>>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" <stampe@city.dkwrote in message
>>news:OSgSEMpTHHA.1036@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
>>>>
>>>
>>>
>>
>>
>>
>
| | | | re: setting focus in ASP 1.1, despite of smartnavigation
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" <nospam@nospam.comskrev i en meddelelse
news:%23t8ODRsTHHA.1200@TK2MSFTNGP04.phx.gbl... Quote:
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: Quote:
>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" <REMOVEALLCAPITALSeEgGoldDinN@mMvVpPsS.orgskrev i en
>meddelelse news:u6FStEqTHHA.3500@TK2MSFTNGP05.phx.gbl... Quote:
>>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" <stampe@city.dkwrote in message
>>news:OSgSEMpTHHA.1036@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
>>>>
>>>
>>>
>>
>>
>>
>
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,510 network members.
|