Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'System.Web.HttpRequest.Form' is a 'property' but is used like a 'meth 2

Status
Not open for further replies.

bouwob

Programmer
Joined
Apr 12, 2006
Messages
171
Location
US
Response.Write("<option value=\"" + Request.Form("countries") + "\">" + Request.Form("countries") + "</option>");


happens on every Request.Form(" ") what am I doing wrong?
 
Firstly, don't use Response.Write to write anything out to the page as it will cause you problems.

Secondly, try square brackets if you are using C#.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
asp or asp.net?
c# or vb?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
asp.net and c#. and if I shouldnt use Response.Write what should I use?
 
It depends what you are trying to do. If you are trying to add a HTML control like it looks like from your example, you should create a new control and add it to the page via the Controls.Add method.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
get a reference to the control and add a list item to the items collection. (i'll assume dropdown)
Code:
MyDropDown.Items.Add(new ListItem(Request.Form["countries"],Request.Form["countries"]));
asp.net seperates markup (presentation) from logic (code). for every web control there is an object to represent that. you don't need to use Response.Write to modify the web form.


Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top