944,106 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 24597
  • ASP.NET RSS
May 9th, 2006
0

onclick dropdown event

Expand Post »
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!!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ceug is offline Offline
3 posts
since May 2006
May 9th, 2006
0

Re: onclick dropdown event

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.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
May 9th, 2006
0

Re: onclick dropdown event

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ceug is offline Offline
3 posts
since May 2006
May 9th, 2006
0

Re: onclick dropdown event

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:

Quote ...
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?
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
May 9th, 2006
0

Re: onclick dropdown event

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ceug is offline Offline
3 posts
since May 2006
May 9th, 2006
0

Re: onclick dropdown event

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.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Need Help
Next Thread in ASP.NET Forum Timeline: drop down list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC