Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2004, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old February 5th, 2004, 12:08 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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.
 
Old February 5th, 2004, 02:44 PM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old February 5th, 2004, 04:35 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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.





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





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