|
|
 |
| ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

March 13th, 2006, 02:11 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Set Focus to Field in User Control
I have a web user control containing a postback enabled checkbox called chkBold. When this check box is clicked, postback occurs and focus on the check box is lost. I want to put focus back on the check box after the form refreshes but this code, contained in the code behind for the check box, isn't working:
RegisterStartUpScript("SetFocus", "<script>document.frmSurveyDefn.TitleStyle.chkBold .focus();</script>")
What is the proper format when referencing an object in a user control?
__________________
PLEASE READ THIS BEFORE RESPONDING: If you have nothing to offer except a lecture on the superiority of Javascript, do not waste your time or mine. I am in an all IE world where I can use VBScript to my heart's content. I choose to use VBScript over Javascript because Javascript is horrendously frustrating to me due to inconsistencies in naming standards and and unnecessary case sensitivity. I would rather not receive assistance than have to read one more sanctimonious lecture about what an idiot I am for using VBScript, OK???
|

March 14th, 2006, 12:51 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
|
|
The names of the controls render differently when a user control renders. To check the name, run your page and do a view source.
What I did to test was I created a WebUserControl with 2 TextBoxes.. TextBox1 and TextBox1. My user control name is WebUserControl1.
To use your code and set the focus to TextBox1 I did this:
RegisterStartupScript("SetFocus", "<script>document.Form1.WebUserControl11_TextBox1.focus();</script>")
Notice how it names the textbox ... All you need to do is view the source of your page and change the code above accordingly.
Hope this helps..
Jim
|

March 14th, 2006, 04:20 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I tried to get it to work but still had no luck. We're finally upgrading to V2 next week, and I understand that it supports a Setfocus method in the browser just like Windows applications. So I'm simply going to hold off until the upgrade and do it the right way. Thanks again!
|

March 14th, 2006, 05:53 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
|
|
ok good luck
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |