Problem auto tabbing
-
Hi all. I have a problem auto-tabbing. I need the text boxes on my form to auto-tab to the next textbox when they're full. I can do this using JavaScript and input controls, but unfortunately, I need to get at the contents of the text boxes using the code behind page. (And I can not for the life of me figure out how to call javascript from an asp:textbox control.) Does anyone have any suggestions of examples on how to do this? (I couldn't find anything that worked with google :/ ) - Munty
-
Hi all. I have a problem auto-tabbing. I need the text boxes on my form to auto-tab to the next textbox when they're full. I can do this using JavaScript and input controls, but unfortunately, I need to get at the contents of the text boxes using the code behind page. (And I can not for the life of me figure out how to call javascript from an asp:textbox control.) Does anyone have any suggestions of examples on how to do this? (I couldn't find anything that worked with google :/ ) - Munty
try this code behind function
public static void SetFocus(Control control) { StringBuilder sb = new StringBuilder(); sb.Append("\r\n\r\n"); sb.Append("<!--\r\n"); sb.Append("function SetFocus()\r\n"); sb.Append("{\r\n"); sb.Append("\tdocument."); Control p = control.Parent; while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent; sb.Append(p.ClientID); sb.Append("['"); sb.Append(control.UniqueID); sb.Append("'].focus();\r\n"); sb.Append("}\r\n"); sb.Append("window.onload = SetFocus;\r\n"); sb.Append("// -->\r\n"); sb.Append(""); control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString()); }
write this code in html view<!-- function SetFocus() { document.Form1['TextBox1'].focus(); } window.onload = SetFocus; // -->
write this code at code behindPageUtility.SetFocus(TextBox1);
regards GV Ramana
-
try this code behind function
public static void SetFocus(Control control) { StringBuilder sb = new StringBuilder(); sb.Append("\r\n\r\n"); sb.Append("<!--\r\n"); sb.Append("function SetFocus()\r\n"); sb.Append("{\r\n"); sb.Append("\tdocument."); Control p = control.Parent; while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent; sb.Append(p.ClientID); sb.Append("['"); sb.Append(control.UniqueID); sb.Append("'].focus();\r\n"); sb.Append("}\r\n"); sb.Append("window.onload = SetFocus;\r\n"); sb.Append("// -->\r\n"); sb.Append(""); control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString()); }
write this code in html view<!-- function SetFocus() { document.Form1['TextBox1'].focus(); } window.onload = SetFocus; // -->
write this code at code behindPageUtility.SetFocus(TextBox1);
regards GV Ramana
I'm using VB as the code behind language :) there is no PageUtility function either. :/ For now im sticking with the tags, as I can get auto tabing to work. My next problem is getting the tags to clear after the page has loaded. (I can't do it on submit because that will clear all of the form, which I don't want. And i cant have a seperate form, because ASP only allows me one form that can run at the server. help! - Munty