I want to loop through all textbox controls to determine
their .text value. If the .text value is not "" then
display the textbox.
I have tried the following with no luck. Any help would
be appreciated.
Dim ctrl as Control
For Each ctrl in Page.Controls
If ctrl.GetType.ToString
= "System.Web.UI.WebControls.TextBox" Then
ctrl.Attributes.Add("style", "DISPLAY: ")
End If
NextYour code is running server side so you may as well take advantage of server control properties rather than worrying about client-side attributes as you have done. See also I have changed the type comparison
Dim ctrl as Contro
For Each ctrl in Page.Control
If ctrl.GetType Is GetType(System.Web.UI.WebControls.TextBox) The
ctrl.Visible = Tru
End I
Nex
hth, ro
--
Posted using Wimdows.net NntpNews Component - Posted from .NET's Largest Community Website: http://www.dotnetjunkies.com/newsgroups/
That didn't work. Here is an example of one of my
textboxes:
<asp:textbox id="txt1" style="DISPLAY: none"
runat="server" Width="80px"></asp:textbox
I am using client side javascript to show / hide the text
box based on the selection of a listbox. I am posting
back to the page after entering text in the textbox.
When posting back all of the textboxes are not displayed
because of the style property (display: none).
Basically I want to display all text boxes when there is
text in them after posting to the page. But I also need
them hidden prior to the listbox selection. Hope I
explained correctly.
>--Original Message--
>Your code is running server side so you may as well take
advantage of server control properties rather than
worrying about client-side attributes as you have done.
See also I have changed the type comparison.
>Dim ctrl as Control
>For Each ctrl in Page.Controls
> If ctrl.GetType Is GetType
(System.Web.UI.WebControls.TextBox) Then
> ctrl.Visible = True
> End If
>Next
>hth, ro.
>
>--
>Posted using Wimdows.net NntpNews Component - Posted
from .NET's Largest Community Website:
http://www.dotnetjunkies.com/newsgroups/
>.
Saturday, March 24, 2012
Loop Through Textboxes
Labels:
asp,
controls,
determinetheir,
loop,
net,
text,
textbox,
textboxes,
thendisplay,
value
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment