Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 5th, 2004, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default Move to the next control using SmartNavigation

Does anyone know how to move to the next control when SmartNavigation is enabled. When I post back to the server, I get the focus set to the current textbox (as it should), but I would like to move to the next textbox automatically if this is possibly without having to code it myself. Since this is an onchange event and posts back to the server when the control loses focus, it makes more sense to not make the user tab twice to go to the next control.

Thanks.

J
  #2 (permalink)  
Old February 5th, 2004, 12:08 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

SmartNavigation is a bit of a misnomer. And it can be a bit of a pain sometimes.
You'll have to code that part yourself. You can preset the focus to any control by writing out a little javascript. Use the RegisterStartupString method of the page to write out the script. You'll need to write out a complete chunk of script including the <script> tags. In the construction of your script, output the clientID of the control you want to advance to, and set it's focus property:

System.Text.StringBuilder sScript = new System.Text.StringBuilder();
sScript.Append("<script language=\"JavaScript\">");
sScript.AppendFormat("document.getElementById({0}) .focus();", ctlMyControl.ClientID);
sScript.Append("</script>");
RegisterStartupScript("focusadvance", sScript.ToString());

The only problem I could foresee with this is the interaction with SmartNavigation. It's possible that there could be problems with that, but I guess you'll have to try it and see.

Peter
------------------------------------------------------
Work smarter, not harder.
  #3 (permalink)  
Old February 5th, 2004, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Thanks Peter,

Just another question. What does the {0} stand for? Is it formatting? I have seen this in several examples in books but it never says what this is supposed to represent (at least not where I can find it). Here are some examples:

--------------------------------------------------------------
Response.Output.Write("Current date and time: {0}", DateTime.Now.ToString())
--------------------------------------------------------------

And:

--------------------------------------------------------------
For f = 50.0 To 99.0 Step 1.0
  Response.Output.Write("<tr><td>{0}</td><td>{1:f}</td></tr>", f, CallFunction(f))
Next
--------------------------------------------------------------

Any place where I could read up on it would be appreciated. Thanks again.

J
  #4 (permalink)  
Old February 5th, 2004, 04:35 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

The {x} is a replacement token. The standard Format() method supports up to 3 argumented replacement objects:

newString = String.Format("{0} {1} {2}.", "This", "goes", "here")

which results in "This goes here." If you want to use more than three items, you can put in more tokens and use just the second argument to the function, passing in a object array. As long as you have enough items in the array to match all the tokens it will work.

You can use the inside of the replacement token for formatting specifics. Take a look at the MSDN Formatting Overview for more.

Peter
------------------------------------------------------
Work smarter, not harder.
 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't move focus to control <control scptech Access VBA 8 October 26th, 2007 12:16 PM
onkeypress move to next control [except when the f kamii47 ASP.NET 2.0 Professional 2 September 11th, 2007 03:47 AM
How to Move Multiple Control on a form at runtime? sivavenugopal VB How-To 1 January 22nd, 2007 01:49 PM
smartNavigation problems geofbirchall ASP.NET 1.0 and 1.1 Basics 1 March 16th, 2005 11:18 AM
SmartNavigation="true" CraigJones ASP.NET 1.0 and 1.1 Basics 2 September 3rd, 2004 01:29 PM



All times are GMT -4. The time now is 09:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.