[英]Server-side data available client-side
What I want to do is make a dropdownlist choices change depending on other dropdownlists on the page. 我要做的是根据页面上的其他下拉列表更改下拉列表的选择。 What I did is write all the possibilities in hidden textboxes.
我所做的就是将所有可能性都写在隐藏的文本框中。 This works, but when there are a lot of choices, the page is slow.
这可行,但是当有很多选择时,页面速度很慢。
Is there a better way to do this? 有一个更好的方法吗?
Thank you for your time 感谢您的时间
The best way to do this is with AJAX. 最好的方法是使用AJAX。 In summary you will need to:
总之,您将需要:
It can be done using some of the available ASP.Net AJAX techniques. 可以使用一些可用的ASP.Net AJAX技术来完成。 If you place the dropdown listboxes in an
UpdatePanel
and set them to asynchronous postback, you can make them appear to refresh on selection. 如果将下拉列表框放在
UpdatePanel
并将其设置为异步回发,则可以使它们显示为在选择时刷新。
Because only the code inside the UpdatePanel
is refreshed, the results are loaded much faster. 因为仅刷新
UpdatePanel
的代码,所以加载结果要快得多。
See this article for a nice example using the updatepanel and a couple of dropdown lists. 有关使用updatepanel和几个下拉列表的漂亮示例,请参见本文 。
As laurencek says AJAX would be end solution for this. 正如劳伦斯克所说,AJAX将是最终解决方案。 On asp.net , there is a good sample provided with a understandable explanation, here .
在asp.net中,提供了简单易懂的解释,一个好的样品在这里 。 A little use of Web Service that might cause some pause but still a good explanation on what you are looking for.
稍微使用Web Service可能会导致一些暂停,但对于要查找的内容仍然有很好的解释。
I'll present one possible scenario. 我将介绍一种可能的情况。
AJAX is the way to go as indicated by all others, you can save yourself time by using code that others already written, for example: http://www.codeproject.com/KB/custom-controls/ajaxdropdownlist.aspx AJAX是所有其他人所指出的方式,您可以使用其他人已经编写的代码来节省时间,例如: http : //www.codeproject.com/KB/custom-controls/ajaxdropdownlist.aspx
This one is pretty old by now but can at least show you what you need. 到目前为止,这已经很老了,但至少可以向您展示您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.