473,657 Members | 2,430 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 2035
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
5185
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
1533
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
1381
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 writing client-side scripting? thanks
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
1253
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 > > the datagrid. And again in:
5
1359
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
15620
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
1965
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
2100
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 AutoPostBack View products that this article applies to. Article ID : 314206 Last Review : February 23,...
0
8402
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7341
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1627
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.