Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: listbox onchange?


Message #1 by "Silas Wild" <SILAS@d...> on Fri, 07 Mar 2003 09:59:07 -0800
Using
http://www.4guysfromrolla.com/webtech/071101-1.shtml
example, I have a list of resources from a MSAccess database.  When the
user selects one of the items in the listbox, I would like him/her to be
automatically redirected to a page that describes the resource s/he
chose from the list.

I did this with a hard coded listbox in
http://adams.dom.washington.edu/resources/index.html
and a little javascript to redirect onchange.

But how to accomplish the same thing in asp.net?  I do not want the user
to have to make an extra key click by adding a submit button.

Thanks.

Message #2 by "Dave Rezoski" <daverezoski@h...> on Fri, 07 Mar 2003 18:14:16 +0000
assuming your listbox has an ID="lb"

C#

on page load, or on control load, add this:

this.lb.Attributes.Add("onchange", "name_of_javascript_function_here");

now when the selection is changed by the user, the javascript function will 
get fired to redirect the user to the new page.  you can probably reuse the 
existing javascript function you already have written.

make sense?

HTH







----Original Message Follows----
From: "Silas Wild" <SILAS@d...>
Reply-To: "ASP.NET" <aspx@p...>
To: "ASP.NET" <aspx@p...>
Subject: [aspx] listbox onchange?
Date: Fri, 07 Mar 2003 09:59:07 -0800

Using
http://www.4guysfromrolla.com/webtech/071101-1.shtml
example, I have a list of resources from a MSAccess database.  When the
user selects one of the items in the listbox, I would like him/her to be
automatically redirected to a page that describes the resource s/he
chose from the list.

I did this with a hard coded listbox in
http://adams.dom.washington.edu/resources/index.html
and a little javascript to redirect onchange.

But how to accomplish the same thing in asp.net?  I do not want the user
to have to make an extra key click by adding a submit button.

Thanks.




_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online  
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

Message #3 by "Silas Wild" <SILAS@d...> on Fri, 07 Mar 2003 12:12:11 -0800
Sorry I'm new at this, take a look at 
http://adams.dom.washington.edu/resources/tindex.aspx
and you will see my javascript function (that worked with the static
page http://adams.dom.washington.edu/resources/index.html)
Also you will see how asp.net translated my <asp:listbox...> to a html
<select...> where I have included the onchange action. I used vb.net to
fill the listbox according to the sample by scott mitchell at 4guys. How
should I change my code so the onchange action will fire the javascript
function "redir2aspx"?
thanks again.

>>> daverezoski@h... 03/07/03 10:14AM >>>
assuming your listbox has an ID="lb"

C#

on page load, or on control load, add this:

this.lb.Attributes.Add("onchange", "name_of_javascript_function_here");

now when the selection is changed by the user, the javascript function
will 
get fired to redirect the user to the new page.  you can probably reuse
the 
existing javascript function you already have written.

make sense?

HTH

Message #4 by "Greg Quinn" <greg@i...> on Mon, 10 Mar 2003 16:57:01 +0200
this.lb.Attributes.Add("onchange", "redir2aspx()");

----- Original Message ----- 
From: "Silas Wild" <SILAS@d...>
To: "ASP.NET" <aspx@p...>
Sent: Friday, March 07, 2003 10:12 PM
Subject: [aspx] Re: listbox onchange?


> Sorry I'm new at this, take a look at 
> http://adams.dom.washington.edu/resources/tindex.aspx
> and you will see my javascript function (that worked with the static
> page http://adams.dom.washington.edu/resources/index.html)
> Also you will see how asp.net translated my <asp:listbox...> to a html
> <select...> where I have included the onchange action. I used vb.net to
> fill the listbox according to the sample by scott mitchell at 4guys. How
> should I change my code so the onchange action will fire the javascript
> function "redir2aspx"?
> thanks again.
> 
> >>> daverezoski@h... 03/07/03 10:14AM >>>
> assuming your listbox has an ID="lb"
> 
> C#
> 
> on page load, or on control load, add this:
> 
> this.lb.Attributes.Add("onchange", "name_of_javascript_function_here");
> 
> now when the selection is changed by the user, the javascript function
> will 
> get fired to redirect the user to the new page.  you can probably reuse
> the 
> existing javascript function you already have written.
> 
> make sense?
> 
> HTH
> 
> 

  Return to Index