473,573 Members | 3,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2028
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.dk wrote in message
news:OS******** ******@TK2MSFTN GP03.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.orgskr ev i en
meddelelse news:u6******** ******@TK2MSFTN GP05.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.dk wrote in message
news:OS******** ******@TK2MSFTN GP03.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
functionalli ty 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.setTimeo ut 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.orgskr ev i en
meddelelse news:u6******** ******@TK2MSFTN GP05.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.dk wrote in message
news:OS******* *******@TK2MSFT NGP03.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
functionallit y 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.RegisterSt artupScript 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******** ********@TK2MSF TNGP04.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.setTimeo ut 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.orgskr ev i en
meddelelse news:u6******** ******@TK2MSFTN GP05.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.dk wrote in message
news:OS****** ********@TK2MSF TNGP03.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
functionalli ty 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.RegisterSt artupScript 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******** ********@TK2MSF TNGP04.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.setTimeo ut 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.orgskr ev i en
meddelelse news:u6******** ******@TK2MSFTN GP05.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.dk wrote in message
news:OS****** ********@TK2MSF TNGP03.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
functionalli ty 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
5183
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 that previously had the focus (smartnavigation doesn't do the trick). Thanks, Marco
3
1531
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
1379
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, except that after the postback, the page is shown reset -- scrolled to the top and with no control having focus. Can I maintain scroll/focus w/o...
4
1182
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
1250
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 > > another frame. It gives me an "Invalid Pointer" error. Not sure why but > > apparently it does not want to play along with a javascripted button in >...
5
1356
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
15609
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
1964
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 displaying pages and pages of rows. When I edit some row below pages 1 the post refreshes back to page one, requiring me to page down to do the input.
1
2091
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 been working on this for days. I am using ASP.NET 2003. Thanks. DanYeung PRB: Controls Lose Focus When You Enable SmartNavigation and...
0
7789
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7800
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8086
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.