James Posted January 14, 2003 Posted January 14, 2003 How do I convert a string to a textbox object? Ex. dim strTest as string strTest="textbox" & 1 'I want to convert strTest to a textbox object Thanks, James Quote
*Experts* Nerseus Posted January 14, 2003 *Experts* Posted January 14, 2003 Are you saying you need to take a string and reference an existing control by name or to create a control using that name? If you want to create a control, that's easy. If you want to reference an existing control by name, it can be done but I'm not sure off-hand. Why would you need to know the control name at runtime (not design time)? Maybe there's an easier way to do what you're needing... -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
James Posted January 14, 2003 Author Posted January 14, 2003 I'm trying to reference an existing control by name. The reason I'm doing this at runtime is because I am trying to add javascript blur() event to alot of textboxes. When the blur() event executes a javascript function will do some calculations. I have a lot of textboxes and I want to streamline my code. Below is what I'm trying to do with the textboxes. I have textboxes with the ids jan3, feb3, mar3...jan13,feb13, mar13 For s = 3 To 13 MonthAttr(jan & s) MonthAttr(feb & s) MonthAttr(mar & s) MonthAttr(apr & s) . . . Next s Private Sub MonthAttr(ByVal mon As Object) mon.Attributes.Add("onblur", "calculate()") End Sub Thanks, James Quote
James Posted January 14, 2003 Author Posted January 14, 2003 If anyone wants to know I found the solution. This converts a string to a object control. month1 = FindControl("jan" & s) James Quote
*Gurus* divil Posted January 14, 2003 *Gurus* Posted January 14, 2003 Next time, please mention that this is an ASP.NET question. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aikeith Posted January 23, 2003 Posted January 23, 2003 Yes, is right forum.... So for my sake... month1 = FindControl("jan" & s) will make a var/object named Month1 that is equivalent to Jan13 for instance??? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.