Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: ASP:Dropdownlist naming?
02-03-2012, 11:30 AM #1
- Join Date
- Nov 2011
- Thanked 0 Times in 0 Posts
I've go a problem with a piece of ASP code that I'm hoping someone will be able to help with?
I'm using an ASP:dropdownlist box to pull some info from a DB, however the page I'm using it on writes the form information back in C#, which means it won't see the drop down unless it has a name, not an ID.
I know that its not as simple as just adding name="appID" in the drop down, because I've tried that already, and it doesn't work.
The c# command for the other fields in the form is:
(Request.Form["Appointment"] != null ? Convert.ToString(Request.Form["Appointment"]).Replace("\"", "\"\"") : "") +
for writing other standard input fields back to the DB, but I don't know how to do it for ASP drop downs, can anyone help?
02-03-2012, 09:10 PM #2
First of all, you are talking about ASP.NET, not ASP. So technically you are in the wrong forum.
ASP.NET *always* assigns a name= to form fields, including dropdownlist.
So you could simply bring the page up in a browser, click on the VIEW menu, click on the SOURCE menu item, and then look in the HTML that ASP.NET is generating to find the name it uses.
HOWEVER... If you are using Request.Form to get values from ASP.NET controls, you are really not using ASP.NET the way it was designed to be used.
That shows how you should be capturing "onchange" for asp:dropdownlist.
Generally speaking, if you find yourself using Request.Form a lot, you haven't really bought into the ASP.NET way of handling forms.
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.