ASP.net Javascript列表框/选择问题 [英] ASP.net Javascript Listbox / Select Problem

查看:59
本文介绍了ASP.net Javascript列表框/选择问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到包含空列表框的回发事件的问题。


我有一个页面,其中我通过JavaScript填充列表框,之后我想将此信息提交到数据库。单击按钮触发我的VB代码listbox.items.count = 0,这是在调试器的page_load顶部找到的。 EnableViewState = True,我想不出还有什么导致它。


请任何帮助真的很感激


我想我的问题类似于这个问题

http://www.thescripts.com/forum/thread339231.html


Edward

I''m having problems with a postback event containing an empty listbox.

I have a page in which i populate a listbox via JavaScript, after which i want to submit this information to a database. Clicking the button to trigger my VB code the listbox.items.count = 0 and this is a found at the top of the page_load in the debugger. EnableViewState=True and i can''t think what else my be causing it.

please any help is really appreciated

I think my problem is similar to this one
http://www.thescripts.com/forum/thread339231.html

Edward

推荐答案

问题在于,由于您使用javascript填充列表框(仅在客户端发生),您的后端(服务器端)不知道这一点并保留它的最后已知状态对象(空的)或者可能在page_load()函数中重新初始化为空。


您可能做的是有一个隐藏字段,其值相同作为列表框的选定值(使用javascript填充它然后使用SUBMIT类型按钮)。真的,你只需要将这些信息返回到服务器端进行处理。
The problem is that since you are populating the listbox with javascript (happens only on client side) your backend (server side) has no knowledge of this and is retaining it''s last known state for the object (which is empty) or possibly it gets re-initialized to empty in your page_load() function.

What you could maybe do is have a hidden field whose value is the same as the selected value of the listbox (use javascript to populate this and then use a SUBMIT type button). Really you just need that information getting back to your server side for processing.


我不是真的在选定的值之后,它的值已添加到列表框中。列表框在开始时为空,但随后由showModalDialog返回的数据填充。有没有办法在回发中发回列表框内容?


甚至使用htmlSelect对象?
I''m not really after the selected value, its values i''ve added to the listbox. the listbox is empty at the start but then is populated by the data returned from a showModalDialog. Is there not a way to send the listbox content back in the postback?

Or even use a htmlSelect object instead?


所有内容列表框可以作为逗号分隔列表进入隐藏字段(或者您可以在服务器代码中稍后解析的其他一些有趣的字符)。


是否必须填充列表框通过JavaScript?您是否可以使用PostBack或任何东西来获取服务器端代码?
All the contents of the listbox could go in a hidden field as a comma seperated list (or some other delimanting character that you can parse later on in your server code).

Does the listbox have to be populated by javascript? Can you not use a PostBack or anything to get your server-side code to populate it?


这篇关于ASP.net Javascript列表框/选择问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆