Newbie help.

J

JeremyWoertink

I have a drop down box, and I want to populate a text box based on
what was selected on the drop down. The drop down contains an ID which
is the primary key for a table i'm using. The other column is the
description. So you select the id from the drop down and it populates
the text box with the appropriate description.


I'm new to ASP.NET and i'm using VB. I don't know how to do this. I
know there is an onChange method for the drop down, but then it sends
me to a spot to write some javascript. I know a little javascript, but
I don't know how to go from javascript to VB so I can query the
database again to get that description that has a the same ID as the
ListBox selected text.

Thanks in advance.


~Jeremy
 
T

Toze

well if you dont have have the description in the client side you don't need
javscript unless you want to use AJAX

so you need a postback to the server

the simplest way
is to enable autopostback in the dropdown
and then catch the event onSelectedIndexChange of the dropdown (server
event) ( if your using vb double click on dropdown to add handler)

query the database and set the textbox text

hope it helps
 
M

Michael Nemtsev

Do you really wanna do it on client side? because it is easy to do in on
server side.

1) check that you dropdownlst has runat="server" attribute
2) add onchange event handler in VS IDE in control properties.
3) set autopostback = true in control properties


right now if u put break point in your .cs onchange menthod it will be hit
each time u change values in drop down list

it means u can put any code there, like extract values from db and fill
other controls with the results
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,223
Latest member
Jurgen2087

Latest Threads

Top