setting focus in ASP 1.1, despite of smartnavigation

  • Thread starter Finn Stampe Mikkelsen
  • Start date
F

Finn Stampe Mikkelsen

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
 
E

Eliyahu Goldin

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
 
F

Finn Stampe Mikkelsen

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 said:
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 said:
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
 
B

bruce barker

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)
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 said:
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 said:
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
 
F

Finn Stampe Mikkelsen

, 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 said:
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)
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 said:
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


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
 
F

Finn Stampe Mikkelsen

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 said:
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)
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 said:
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


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top