473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HtmlSelect and PostBack?


I created an HtmlSelect in my ASP.NET page template (setting
runat="server" in its tag), double-clicked it in the Designer, and
Visual Studio automagically made the declaration and Event Wireup and
associated method.

However, I use JavaScript on the client to populate the list and a
LinkButton to PostBack. In the Page_Load, there are no items in the
HtmlSelect.

Does anyone have an example of how this should work?

Thanks.
Nov 19 '05 #1
3 3336
The problem with what you are doing is that ASP.NET generates the object
model for the page during the Page_Init event. In order for the server to
dispatch to the event handler for the control, the control must be fully
formed before the Load event happens. If you populate it on the client,
there is no way for the server to know what items are available and
therefore will not dispatch to the event.

In other words, you will have to do this some other way such as storing
information in a hidden field and then process it yourself during the
Page_Load.

"xenophon" <xe******@online.nospam> wrote in message
news:6l********************************@4ax.com...

I created an HtmlSelect in my ASP.NET page template (setting
runat="server" in its tag), double-clicked it in the Designer, and
Visual Studio automagically made the declaration and Event Wireup and
associated method.

However, I use JavaScript on the client to populate the list and a
LinkButton to PostBack. In the Page_Load, there are no items in the
HtmlSelect.

Does anyone have an example of how this should work?

Thanks.

Nov 19 '05 #2
Xeno:
Check out http://openmymind.net/FAQ.aspx?documentId=1

Client-side added controls won't show up on the server side because the
viewstate has already been rendered. You can still use Request.Form() to
get the selected values though.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"xenophon" <xe******@online.nospam> wrote in message
news:6l********************************@4ax.com...

I created an HtmlSelect in my ASP.NET page template (setting
runat="server" in its tag), double-clicked it in the Designer, and
Visual Studio automagically made the declaration and Event Wireup and
associated method.

However, I use JavaScript on the client to populate the list and a
LinkButton to PostBack. In the Page_Load, there are no items in the
HtmlSelect.

Does anyone have an example of how this should work?

Thanks.

Nov 19 '05 #3
When you are populating a Select control on the client side, absolutely
nothing of this is sent back by the browser to the server and only the
selected value is posted back. This is the normal behavior of the browser.

S. L.

"xenophon" <xe******@online.nospam> wrote in message
news:6l********************************@4ax.com...

I created an HtmlSelect in my ASP.NET page template (setting
runat="server" in its tag), double-clicked it in the Designer, and
Visual Studio automagically made the declaration and Event Wireup and
associated method.

However, I use JavaScript on the client to populate the list and a
LinkButton to PostBack. In the Page_Load, there are no items in the
HtmlSelect.

Does anyone have an example of how this should work?

Thanks.

Nov 19 '05 #4

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

Similar topics

6
by: BK | last post by:
I'm having a really strange problem with and HtmlSelect server control (listbox) and a RequiredFieldValidator that I am trying to use to make sure that someone has items in the listbox. The way...
1
by: Suhail A, Salman | last post by:
Dear All, I placed a HtmlSelect control on a web page and set it to "Run at Server", the objective of this HtmlSelect control is that the client adds all his accounts to a text box, and...
4
by: nospam | last post by:
HtmlSelect has a method called OnServerChange that supposed to detect whether the control (select) has changed on a postback. This is not all that useful. It should be like the asp.net...
2
by: Stephen Miller | last post by:
When I dynamically populate a HtmlSelect combo box, the Value property consistently fails to return the item selected, defaulting instead to the first item in the list. For example: Protected...
0
by: Zoodor | last post by:
I have a server control that contains an HtmlSelect. It currently uses postbacks to function (and works fine), but I am upgrading it to be able to use callbacks (using postback or callback,...
1
by: Ken | last post by:
I have an HTMLSelect server control that I am populating dynamically in the Page_Load event of my page. When I turn off VIEWSTATE, the HTMLSelect.Value property is blank when the page is posted...
3
by: Joe | last post by:
Hello All, I am populating an HtmlSelect control's Items property with four list items. The HtmlSelect control is contained in a user control which is dropped into a placeholder on the web form....
2
by: mirlisa | last post by:
I'm using an HtmlSelect (runat=sever). I add the items programmatically and I also add a custom attribute to each listitem because I need to track an additional field value. I'm having a...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.