473,698 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox does not appear in Request.Form

DropDown lists and Listboxes do not appear in the list of controls and
values passed back to the server on PostBack in Request.Form object. Can
someone confirm this to be correct and possibly answer why ?

The impact of this is that values added via javascript will never make it
back to the server side code unless one does some jiggery pokery with hidden
fields etc. If this is true, then I would like to understand the reason
behind the design decision and if this has been addressed in VS2005 ?
Cheers - Mr N
Nov 19 '05
10 3465
I found another way around this. If you hijack the form submit, you can
select all members of the ListBox and then submit the code, this is only any
good if you dont want to select a single item from the list. Otherwise your
hidden field idea is the only way forward.

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

If IsPostBack Then

Dim col As System.Collecti ons.Specialized .NameValueColle ction

Dim listItemsArray( ) As String

Dim strListItems As String

col = Request.Form

strListItems = col.Item("ListB ox1")

listItemsArray = strListItems.Sp lit(",")

ListBox1.Items. Clear()

For Each s As String In listItemsArray

ListBox1.Items. Add(s)

Next



End If


"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
No, I think you are right about that part :) i could look into it, but
let's say you are...can't think of how else it would do it ...nice catch!

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Mr Newbie" <he**@now.com > wrote in message
news:eq******** ******@TK2MSFTN GP14.phx.gbl...
OK, that makes sense I suppose. Presumably though viewstate is used with
textboxes to determine and fire the text changed event by comparing the
text before and that which is preserved in viewstate, or do I have that
wrong as well.

I dont seem to be doing very well today!

Cheers Mr N

Just to clarify in addition to my post...TextBoxe s don't work like you
think they do with ViewState. The value of a textbox isn't preserved
via ViewState. Since there's only 1 value and HTML specifications say
that the value has to be passed via REquest.Form, it would be foolish
for ASP.Net to also maintain it in ViewState (waste of space).

ViewState is used where/when Request.Form can't. Namely for controls
that don't participate in the form submission (datagrid for example) as
well as controls who only partially participate in form submission (only
the selected radio input gets passed).



Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7301
by: Crystal | last post by:
Ok, I know this sounds weird, but it's really bugging me. I have a few list boxes on my form (basic pick a month, year, state stuff) and you can only choose one value. I need to be able to run a script to pick out those boxes and request the value and then response.write the value to a URL that I am creating. The script actually sends an email to me that contains a link to the form that the user filled in and populates the form with...
4
2309
by: f_salazar | last post by:
English Version !! Hi !! I have a page with a Form, inside the form I have listbox with 'X' elements. Wend I submit the page, an ASP process inside the page have to read those elements and then save them in a database. I try Request.Form("listbox") but doesnt work !
1
3574
by: Annette Massie | last post by:
I would like to have a form that lists current addresses being used. On this form I would also like to have a command button that would allow the user to add an address if they do not see it listed. Is it possible to have the form show the list box (which is a combinination of the address and city/state/zip), along with the detail fields address and city/state/zip? I guess I was thinking of have the listbox display and then when the...
9
6999
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have it return the associated records to a listbox. Once the listbox has the records, I want to select a record, which will open a form associated with the selected record in the listbox.
0
2299
by: Ray | last post by:
Folks, I have just created a simple procedure that does the following: Determines the width of the columns of a listbox. Places a button of the correct size above each column as the form opens. Sorts by that column when you click the button. Automatically toggles between ASC and DESC sort sequence. To implement it on a new form, you simply copy the buttons from my
13
7662
by: Gittyup | last post by:
Help please, We have a form, based on a query, that contains a listbox. The contents of the listbox are based on the results of the query. When the form is opened, the user selects an item from the listbox, and, using the AfterUpdate and Visible properties, a subform appears with information relative to the selected item. It works perfectly.
1
8394
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What I want to do is to allow the user to click on the row that corresponds to the correct address, and have the code behind populate the form's Address1, Address2 etc. controls with the relevant data items. I put the code for this into the...
6
5212
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I have also tried changing the second ListBox to an HtmlSelect control) using bog standard JavaScript code like so where "used" is the name of my <select> control: used.options = new Option(name, typeId); This all works fine and I can move across...
5
2665
by: MelindaM | last post by:
Hi guys, I created a form for searching through a parts library that I have stored in a MySQL database. I'm not new to web programming but this is my first time using PHP and Ajax. I have four listboxes that are chained together. In other words, if you click on the first one it filters out what's available in the next three. If you click on the 3rd one, it filters out the available options in the 4th one, etc. I do this by having php pages...
0
8668
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8855
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7708
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.