| | |
onclick dropdown event
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 3
Reputation:
Solved Threads: 0
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!!
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!!
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
I go into detail about the client-server nature of ASP.NET with these articles.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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:
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?
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?
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
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.
![]() |
Similar Threads
- Detect browser window closing event in Firefox - (JavaScript / DHTML / AJAX)
- Javascript event & color change problem (JavaScript / DHTML / AJAX)
- Gettig delphi to wait for a button press before continuing (Pascal and Delphi)
Other Threads in the ASP.NET Forum
- Previous Thread: Need Help
- Next Thread: drop down list
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical objects opera panelmasterpagebuttoncontrols radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers






