p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 13th, 2006, 02:11 PM
Friend of Wrox
Points: 1,729, Level: 16
Points: 1,729, Level: 16 Points: 1,729, Level: 16 Points: 1,729, Level: 16
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old March 14th, 2006, 12:51 AM
Friend of Wrox
Points: 4,166, Level: 27
Points: 4,166, Level: 27 Points: 4,166, Level: 27 Points: 4,166, Level: 27
Activity: 12%
Activity: 12% Activity: 12% Activity: 12%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old March 14th, 2006, 04:20 PM
Friend of Wrox
Points: 1,729, Level: 16
Points: 1,729, Level: 16 Points: 1,729, Level: 16 Points: 1,729, Level: 16
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Jun 2003
Location: Denver, CO, USA.
Posts: 342
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old March 14th, 2006, 05:53 PM
Friend of Wrox
Points: 4,166, Level: 27
Points: 4,166, Level: 27 Points: 4,166, Level: 27 Points: 4,166, Level: 27
Activity: 12%
Activity: 12% Activity: 12% Activity: 12%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,328
Thanks: 0
Thanked 1 Time in 1 Post
Default

ok good luck

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Set focus on a particular field after server side vinodonline2000 ASP.NET 2.0 Basics 1 March 6th, 2008 09:15 AM
USER CONTROL FOCUS PROBLME ......PLZ. HELP ME meerraj ASP.NET 1.0 and 1.1 Professional 1 February 28th, 2007 06:29 AM
Set focus on web control vivekshah ASP.NET 1.0 and 1.1 Professional 1 June 19th, 2006 12:55 AM
set Focus to web control in Web form vivekshah C# 1 June 17th, 2006 04:25 AM
Can't get focus on user control drb2k2 C# 2 December 15th, 2004 12:51 PM



All times are GMT -4. The time now is 04:49 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc