473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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
Feb 12 '07 #1
5 2008
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
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
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
, 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


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marco Liedekerken | last post by:
Hi, Is it possible to retrieve the control that had the focus when the page was posted back? Because the focus is lost when a postback occurs I want to manually set the focus to the control...
3
by: Grey | last post by:
Can I set a specific control on focus? My case is after I click a "Submit" button, I want to set the cursor on a textbox . Million thanks
6
by: Mike | last post by:
I have a few textbox controls that have autopostback so that when they loose focus they update a label control that shows the count of characters in their respective text control. This works fine,...
4
by: Wayne Wengert | last post by:
How can I have the focus on a specific textbox when a page opens? In the old ASP pages I could use an onload directive in the <Body> element but that does not work on my aspx pages? Wayne
0
by: Jim Fisher | last post by:
"Skeptical" wrote concerning SmartNavigation: > > Thanks a lot that is exactly what I have been looking for. It works in a > > standard row selecting case but somehow fails when I open > >...
5
by: Glenn T. Kitchen | last post by:
Hello All, Does anyone know how to set the focus to a textbox control on Page_Load? Thank you, Glenn
2
by: ad | last post by:
I used ASP.NET 2.0. When I edit a row in a GridView. How can I set the focus to the first editable column?
2
by: jason | last post by:
Hello and Good Day. REALLY LOST. Running ASP.NET 1.1 Becuase I think I'm using my own controls smartnavigation does not appear to work for me. Stardard issue: I've got a datagrid thats...
1
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.