Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HtmlSelect and PostBack?

Reply
Thread Tools

HtmlSelect and PostBack?

 
 
xenophon
Guest
Posts: n/a
 
      03-07-2005

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.


 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      03-07-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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.
>
>



 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      03-07-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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.
>
>



 
Reply With Quote
 
Sylvain Lafontaine
Guest
Posts: n/a
 
      03-07-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HtmlSelect and RequiredFieldValidator BK ASP .Net 10 05-04-2005 02:04 PM
Problem with HTMLSelect.SelectedIndex and client disabled property Harry Keck ASP .Net Web Controls 0 01-27-2005 03:19 PM
ASP.NET 2.0: Are they going to fix HtmlSelect? nospam ASP .Net 4 10-16-2003 02:53 PM
accessing elements added htmlselect using javascript Suhail A, Salman ASP .Net 1 08-13-2003 12:28 PM
HtmlSelect control is not helping and client side coding became a real headache Suhail A, Salman ASP .Net 0 08-13-2003 10:38 AM



Advertisments