Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-03-2012, 10:30 AM   PM User | #1
Hayezy
New Coder

 
Join Date: Nov 2011
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
Hayezy is an unknown quantity at this point
ASP:Dropdownlist naming?

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?
Hayezy is offline   Reply With Quote
Old 02-03-2012, 08:10 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
First of all, you are talking about ASP.NET, not ASP. So technically you are in the wrong forum.

However...

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.

Look here:
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

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.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:52 PM.


Advertisement
Log in to turn off these ads.