Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reference textbox dynamically 2

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
US

Please what is wrong with this code?
Code:
Private Sub UpdateAnswer(ByVal question As Integer, ByVal answer As Integer)
        Dim x As Integer
        Dim t As TextBox
        Dim b As Button
        t = "textbox" & question
        t.Text = answer
        For x = 1 To 5
            b = "Button" & x
            b.BackColor = b.BackColor.White()
        Next
        ("Button" & answer).BackColor = ("Button" & answer).BackColor.Black()
    End Sub

LikeThisName <- ?
 
I'm not entirely sure about the vb.net implementation, but in c# it would be something like:

Code:
this.FindControl("textbox" + question).Text = answer;

this.FindControl("Button" + x).BackColor = System.Drawing.Color.White;

this.FindControl("Button" + answer).BackColor = System.Drawing.Color.Black;

Hopefully that helps (sorry, don't know vb.net).

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
Thanks you two, for valuable posts.

This code worked:

Code:
Private Sub UpdateAnswer(ByVal question As Integer, ByVal answer As Integer)
        Dim x As Integer
        Dim t As TextBox
        Dim b As Button
        t = Page.FindControl("Textbox" & question)
        t.Text = answer
        For x = 1 To 5
            b = Page.FindControl("Button" & x)
            b.BackColor = b.BackColor.White()
        Next
        b = Page.FindControl("Button" & answer)
        b.BackColor = b.BackColor.Black()
    End Sub

LikeThisName <- ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top