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 10 3451
Hello, Mr. Newbie.
re: 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
JavaScript runs client-side and forms run server-side.
You need to pass the values to the server from your javascript,
which is running where the server will never see it.
re: If this is true, then I would like to understand the reason behind the design decision and if this has been addressed in VS2005 ?
..
The reason is "by design", per the explanation above.
What I wonder is why you are still sticking to Request.Form,
instead of using the .NET native Request.Params, which returns
a combined collection of QueryString, Form, ServerVariables , and Cookies.
Request.Params works the same way in ASP.NET 1.x, 2.0 and WinFx : http://msdn.microsoft.com/library/de...aramstopic.asp http://msdn2.microsoft.com/en-us/library/dt24b615 http://winfx.msdn.microsoft.com/libr...est_Params.asp
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
This isn't an ASP.Net issue, it's how HTML and HTTP work. For list
controls, such as <input type="radio/checkbox" and <select> only the
SELECTED value is passed in the Request.Form. This is how the first form
worked in HTML 1.0 and how it works now.
ViewState tries to resolve this problem by taking all the values before the
page is rendered and serializing said values to a hidden field, which can
then be used to recreate the controls on postback. If you have a listbox
with 10 items, then those 10 items will be serialized to a hidden field. if
you dynamically add an 11th item using javascript to the control, the value
still won't be added to the hidden field and thus won't appear during
postback. This is neither a bug nor a limitation of ASP.Net.
You need to do some hidden field trick. It's often easier to copy the
selected value to a hidden field (assuming you need to know what the
selected value was) and then select all the values in the
Select/radio/checkbox It results in less code...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Mr Newbie" <he**@now.com > wrote in message
news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
I dont think you have understood me, perhaps I did not make myself clear.
I am well aware that Javascript runs client side and web forms run server
side. The question is regarding ListBox and DropDown boxes. Why does ASP.NET
not preserve the 'STATE' of those controls ?
The point being is that controls such as TextBox's and Buttons etc have
their state preserved by using the Viewstate. For example if I add client
side a charavter to a textbox, ASP.NET will update the viewstate and whent
the form is posted back to the client. That change is reflected. However,
with ListBox and DropDown, this is not the case ( Apparently ) , the
question is why ?
This is not really anything to do with Javascript other than this is how I
would add items client side if I wanted to.
Does this make my question clearer ?
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:OH******** ******@tk2msftn gp13.phx.gbl... Hello, Mr. Newbie.
re: 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
JavaScript runs client-side and forms run server-side.
You need to pass the values to the server from your javascript, which is running where the server will never see it.
re: If this is true, then I would like to understand the reason behind the design decision and if this has been addressed in VS2005 ? . The reason is "by design", per the explanation above.
What I wonder is why you are still sticking to Request.Form, instead of using the .NET native Request.Params, which returns a combined collection of QueryString, Form, ServerVariables , and Cookies.
Request.Params works the same way in ASP.NET 1.x, 2.0 and WinFx :
http://msdn.microsoft.com/library/de...aramstopic.asp
http://msdn2.microsoft.com/en-us/library/dt24b615
http://winfx.msdn.microsoft.com/libr...est_Params.asp
Juan T. Llibre, ASP.NET MVP ASP.NET FAQ : http://asp.net.do/faq/ Foros de ASP.NET en Español : http://asp.net.do/foros/ =============== =============== ======== "Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
> This isn't an ASP.Net issue, it's how HTML and HTTP work. For list controls, such as <input type="radio/checkbox" and <select> only the SELECTED value is passed in the Request.Form. This is how the first form worked in HTML 1.0 and how it works now.
I tried selecting a value which was added using Javascript, but this did
not get passed back either. So are you saying then that only the selected
value or values are passed back if the values were generated by asp.net ?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:eY******** *******@TK2MSFT NGP15.phx.gbl.. . ViewState tries to resolve this problem by taking all the values before the page is rendered and serializing said values to a hidden field, which can then be used to recreate the controls on postback. If you have a listbox with 10 items, then those 10 items will be serialized to a hidden field. if you dynamically add an 11th item using javascript to the control, the value still won't be added to the hidden field and thus won't appear during postback. This is neither a bug nor a limitation of ASP.Net.
You need to do some hidden field trick. It's often easier to copy the selected value to a hidden field (assuming you need to know what the selected value was) and then select all the values in the Select/radio/checkbox It results in less code...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
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).
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Mr Newbie" <he**@now.com > wrote in message
news:ur******** *****@TK2MSFTNG P12.phx.gbl... I dont think you have understood me, perhaps I did not make myself clear.
I am well aware that Javascript runs client side and web forms run server side. The question is regarding ListBox and DropDown boxes. Why does ASP.NET not preserve the 'STATE' of those controls ?
The point being is that controls such as TextBox's and Buttons etc have their state preserved by using the Viewstate. For example if I add client side a charavter to a textbox, ASP.NET will update the viewstate and whent the form is posted back to the client. That change is reflected. However, with ListBox and DropDown, this is not the case ( Apparently ) , the question is why ?
This is not really anything to do with Javascript other than this is how I would add items client side if I wanted to.
Does this make my question clearer ?
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message news:OH******** ******@tk2msftn gp13.phx.gbl... Hello, Mr. Newbie.
re: 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
JavaScript runs client-side and forms run server-side.
You need to pass the values to the server from your javascript, which is running where the server will never see it.
re: If this is true, then I would like to understand the reason behind the design decision and if this has been addressed in VS2005 ? . The reason is "by design", per the explanation above.
What I wonder is why you are still sticking to Request.Form, instead of using the .NET native Request.Params, which returns a combined collection of QueryString, Form, ServerVariables , and Cookies.
Request.Params works the same way in ASP.NET 1.x, 2.0 and WinFx :
http://msdn.microsoft.com/library/de...aramstopic.asp
http://msdn2.microsoft.com/en-us/library/dt24b615
http://winfx.msdn.microsoft.com/libr...est_Params.asp
Juan T. Llibre, ASP.NET MVP ASP.NET FAQ : http://asp.net.do/faq/ Foros de ASP.NET en Español : http://asp.net.do/foros/ =============== =============== ======== "Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
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).
See Karl's answer for specific recommendations .
Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
=============== =============== ========
"Mr Newbie" <he**@now.com > wrote in message news:ur******** *****@TK2MSFTNG P12.phx.gbl... I dont think you have understood me, perhaps I did not make myself clear.
I am well aware that Javascript runs client side and web forms run server side. The question is regarding ListBox and DropDown boxes. Why does ASP.NET not preserve the 'STATE' of those controls ?
The point being is that controls such as TextBox's and Buttons etc have their state preserved by using the Viewstate. For example if I add client side a charavter to a textbox, ASP.NET will update the viewstate and whent the form is posted back to the client. That change is reflected. However, with ListBox and DropDown, this is not the case ( Apparently ) , the question is why ?
This is not really anything to do with Javascript other than this is how I would add items client side if I wanted to.
Does this make my question clearer ?
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message news:OH******** ******@tk2msftn gp13.phx.gbl... Hello, Mr. Newbie.
re: 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
JavaScript runs client-side and forms run server-side.
You need to pass the values to the server from your javascript, which is running where the server will never see it.
re: If this is true, then I would like to understand the reason behind the design decision and if this has been addressed in VS2005 ? . The reason is "by design", per the explanation above.
What I wonder is why you are still sticking to Request.Form, instead of using the .NET native Request.Params, which returns a combined collection of QueryString, Form, ServerVariables , and Cookies.
Request.Params works the same way in ASP.NET 1.x, 2.0 and WinFx :
http://msdn.microsoft.com/library/de...aramstopic.asp
http://msdn2.microsoft.com/en-us/library/dt24b615
http://winfx.msdn.microsoft.com/libr...est_Params.asp
Juan T. Llibre, ASP.NET MVP ASP.NET FAQ : http://asp.net.do/faq/ Foros de ASP.NET en Español : http://asp.net.do/foros/ =============== =============== ======== "Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
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).
No, you should be seeing the value in Request.Form
Request.Form is totally independant of ViewState or server-side this or
client-side that...it's much more basic than all of that. Whatever value is
selected, however it got there, should show up. The only thing I can think
of, without seeing code, is that ASP.Net does generate unique clientId's so
if you have
<asp:dropdownli st id="SomeId" runat="server" />
it might get rendered as
<select name="clt0:Some Id" > ... </select>
Form submission works on Name not Id, so I only showed the Name.
Anyways, you might be doing Request.Form["SomeId"] when really you should
be doing Request.Form[someId.ClientId] but that'll only happen when your
controls are nested.
Two things you can do. Turn tracing on in the page <%@ Page trace="True"
.... %> and look at the output, or debug, add a breakpoint in Page_Load and
Add a Watch to REquest.Form
karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"Mr Newbie" <he**@now.com > wrote in message
news:ec******** ******@TK2MSFTN GP14.phx.gbl... This isn't an ASP.Net issue, it's how HTML and HTTP work. For list controls, such as <input type="radio/checkbox" and <select> only the SELECTED value is passed in the Request.Form. This is how the first form worked in HTML 1.0 and how it works now.
I tried selecting a value which was added using Javascript, but this did not get passed back either. So are you saying then that only the selected value or values are passed back if the values were generated by asp.net ?
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:eY******** *******@TK2MSFT NGP15.phx.gbl.. . ViewState tries to resolve this problem by taking all the values before the page is rendered and serializing said values to a hidden field, which can then be used to recreate the controls on postback. If you have a listbox with 10 items, then those 10 items will be serialized to a hidden field. if you dynamically add an 11th item using javascript to the control, the value still won't be added to the hidden field and thus won't appear during postback. This is neither a bug nor a limitation of ASP.Net.
You need to do some hidden field trick. It's often easier to copy the selected value to a hidden field (assuming you need to know what the selected value was) and then select all the values in the Select/radio/checkbox It results in less code...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ "Mr Newbie" <he**@now.com > wrote in message news:OH******** *****@TK2MSFTNG P15.phx.gbl... 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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 !
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |