redmission
asked on
ASP.NET - Add Attributes To All Text Boxes On Page
I have this code, and it works:
With Me
.txtFullName.Attributes.Ad d("onfocus ", "this.style.backgroundColo r='#F4EDBD ';")
.txtFullName.Attributes.Ad d("onblur" , "this.style.backgroundColo r='#FFFFFF ';")
End With
I want to do this with ALL text boxes on the page though. How can I loop through all the controls and do this just for the text boxes so I want have to manually type all the ID names for the text boxes? I have my code in the Page_Load event.
With Me
.txtFullName.Attributes.Ad
.txtFullName.Attributes.Ad
End With
I want to do this with ALL text boxes on the page though. How can I loop through all the controls and do this just for the text boxes so I want have to manually type all the ID names for the text boxes? I have my code in the Page_Load event.
ASKER
I put this code in the Page Load event. It's the only code in that event. And it doesn't work on the page. I tested in Firefox, IE, Safari...Javascript enabled in all browsers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yeh thats strange. Ah well you got it working now.
For Each c In Page.Controls
'TextBox
If (c.GetType().ToString().Eq
Dim tb As TextBox = DirectCast(c, TextBox)
tb.Attributes.Add("onfocus
tb.Attributes.Add("onblur"
End If
Next