Asp.Net列表框和JQuery [英] Asp.Net ListBox and JQuery

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

问题描述

我们有一个包含禁用列表框(位于codebehind)的页面。这个列表框可以通过检查页面上的复选框来enabeled;它被重新启用与使用JQuery的JavaScript。

We have a page that contains a ListBox that is disabled (in the codebehind). This ListBox can be enabeled by checking a checkbox on the page; it gets re-enabled with javascript using JQuery.

因此​​,问题是当控制是第一禁用然后在网页重新启用,它不具有一个选择的项目,即使一个被选择

So, the problem is when the control is first disabled then re-enabled on the page, it does not have a selected item even if one is selected.

如果ListBox中是从来没有在codebehind禁止同一code正常工作。

The same code works fine if the ListBox was never disabled in the codebehind.

有什么办法重新启用列表框,使用JQuery,所以选取的值将被发送到服务器?

Is there any way to re-enable the ListBox, using JQuery, so the selected values will be posted to the server?


这是使用VS 2005和.NET程序2.0项目中没有.NET MVC

this is a .net 2.0 project using VS 2005 and no .NET MVC

推荐答案

您将需要拿出一个解决方案,ListBox中总是启用服务器端和可见。所以一个jQuery,唯一的解决办法,以禁用选择。我想补充一个隐藏字段,有它存储开关与否的选择应该启用。这将使你的jQuery code向控件是否在回传时启用服务器报告。

You will need to come up with a solution where the ListBox is always server-side enabled and visible. So a jQuery-only solution to disabling a select. I would add a hidden field, have it store a switch for whether or not the select should be enabled. This will allow your jQuery code to report to the server whether or not the control was enabled at the time of postback.

您显然必须写jQuery的code扳平隐藏字段,并选择一起和管理已禁用/启用状态。

You would obviously have to write jQuery code to tie the hidden field and select together and manage the disabled/enabled state.

编辑:现在,我想它。你可以得到选择从的Request.Form 收藏的价值,并在<$分配价值,你的的ListBox C $ C> Page_Init 。你会失去任何的ListBox。*更改事件。

Now that I think about it. You could get the value of the select from the Request.Form collection and assigning the value to your ListBox during Page_Init. You would lose any ListBox.*Changed events.

这篇关于Asp.Net列表框和JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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