Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • *Experts*
Posted

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

"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
Posted

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

Posted

If anyone wants to know I found the solution. This converts a string to a object control.

 

month1 = FindControl("jan" & s)

 

James

  • 2 weeks later...
Posted

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???

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...