C# textbox question

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
M

Maziar Aflatoun

Hi,

I'm dynamically creating text boxes (<asp:textbox>) based on the column
names in database. Now, I might have a textbox with id="Your height", how
would I read the value of that in my codebehind file?

I tried Request.QueryString["Your height"] and it doesn't work?

Thank you
Maziar A.
 
The Querystring won't work as that would only be if you're adding the values
of them to the URL as a variable. If it's a normal ASP.Net page then it will
be using the POST method by default, in which case you can use
Request.Forms. You can also use the FindControl method of the page object to
get an isntance of the control (ie: TextBox tb =
(TextBox)Page.FindControl("YourHeight");) If you're creating them
dynamically then they only exist after you instantiate them so the
FindControl method will only work if you've instantiated the objects
already.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrotnPage
 
Back
Top