onclick dropdown event

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2006
Posts: 3
Reputation: ceug is an unknown quantity at this point 
Solved Threads: 0
ceug ceug is offline Offline
Newbie Poster

onclick dropdown event

 
0
  #1
May 9th, 2006
hello,
I've a empty dropDownList. When it is clicked, i want to go to the server and fill it with the appropriate data.
My problem is that dropDownList has few events and has no
click event.
I thought about catching the event as client event and then call the server method that fills the data (is it possibale and how?).
I tried with this (at the code behind) and it works ok, to go to the client when the dropdown is clicked:
DropDownApp.Attributes.Add("onclick", "Fill(this);");

but I can´t figure out how to fill the dropdown from client-side.

other ideas (with example) will be highly appreaciated.
thanks!!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: onclick dropdown event

 
0
  #2
May 9th, 2006
Why aren't you filling the dropDownList server-side, prior to delivery to the client?

I go into detail about the client-server nature of ASP.NET with these articles.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3
Reputation: ceug is an unknown quantity at this point 
Solved Threads: 0
ceug ceug is offline Offline
Newbie Poster

Re: onclick dropdown event

 
0
  #3
May 9th, 2006
I have to fill it just when the user clicks on the combo...I don´t know how to do this, and as the dropdownlist control doesn´t have the onclick event, I thought using the client event.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: onclick dropdown event

 
0
  #4
May 9th, 2006
Yes, but, why? What I'm telling you is that this approach is unconventional. If you have enough information to fill the list when someone clicks it, you have enough information to fill it before it is clicked.

My suggestion is, the flaw is with your approach, not with the dropdownlist.

So again:

Why aren't you filling the dropDownList server-side, prior to delivery to the client?
You cannot fill the list client-side, unless the data to fill it is present client-side. How would the data be available? Only if you put it there, server-side. And if you can do that... why not just fill the list?
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3
Reputation: ceug is an unknown quantity at this point 
Solved Threads: 0
ceug ceug is offline Offline
Newbie Poster

Re: onclick dropdown event

 
0
  #5
May 9th, 2006
Yes, I should fill the combo with a dataset.
Yes, sure...but is the way the client wants...Also because the are two combos(in addition to mine), and each sql query takes a lot of time...so, if I fill the two combos simultaneously, it would take too much time.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: onclick dropdown event

 
0
  #6
May 9th, 2006
More time than it would take to fill them slowly, one at a time, with server round-trips throw in? NO WAY.

Plus, you can likely combine your queries to return all the results in a single recordset. You don't have to use a dataset, you can can do all your queries at page load, store the results someowere (dataset, arraylist, etc.) and bind that to your dropdowns.

Trust me: you cannot do this "client-side", because a client script cannot access a database, do a query, bind to a server-control, etc.

You can either code a JavaScript "submit()" to go fetch the data via server-side code, which is slower than just doing it in the first place, or you can code something using AJAX to retrieve the data (in ASP.NET they call it a "Script CallBack"), also slower than doing it upfront.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC