Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
Is there a way to find out the type of a given control on an ASP form? For instance, I'm going through each of the controls on a form, and I want to know if it's a text box, select list, or whatever.
Posted
you can use typeof, for example

 

if typeof ctrl is textbox then

 

'your code

 

end if

 

Right now, my loops through a collection of controls, as such:

Dim coll as NameValueCollection

coll = HttpContext.Current.Request.Form

For i = 0 to coll.Count - 1
    'Do something to each control.
Next i

 

Does the NameValueCollection allow me to get the control variables? If not, is there a better way to loop through each control on the form?

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