组合框 ajaxcontrol

发布于 2024-10-14 00:14:07 字数 340 浏览 5 评论 0原文

我有一个带有 5-6 个组合框 ajax 控制工具包的过滤器面板..

我希望此过滤器面板默认可见 false..并在客户端单击时使用 java 脚本切换它(显示/隐藏),

但是当我有过滤器时面板可见 = false runat=服务器 java 脚本未获取对象

,如果我在后面执行代码..filterpanel.attributes.add("style",display:none) filterpanel.attributes.add("style",visibilty:hidden)

组合框抛出运行时错误..

我在网上搜索说..组合框很难在面板内呈现..其默认属性最初是错误的!

i have a filter panel with 5-6 combo boxes ajax control tool kit..

i want this filter panel to be visible false by default.. and toggle it(show/hide) on client click using java script

however when i have my filter panel as visible = false runat=server java script does not get the object

and if i do code behind.. filterpanel.attributes.add("style",display:none)
filterpanel.attributes.add("style",visibilty:hidden)

the combo box throws a runtime error..

i've searched on the net which says.. combo box is difficult to render inside a panel.. whose default property is initially false!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

假装不在乎 2024-10-21 00:14:07

问题是

因此 display: none; 将不起作用,因为元素未渲染,而 visibility: hide; 将部分起作用,因为元素已渲染,因此为它们分配了空间在页面上,但隐藏,因此空间将保持空白。

第三种解决方案是照常渲染容器,但使其绝对定位 在浏览器视口之外:

filterPanel.Attributes.Add("style",
    "position: fixed; left: -10000px; top: -10000px;");

这样,面板及其内容将不可见,但

在客户端,显示面板的公式变为:

document.getElementById("filterPanelClientID").style.position = "static";

并再次隐藏它:

document.getElementById("filterPanelClientID").style.position = "fixed";

您可以在 此处测试基于 jQuery 的实现

The problem is that the <select> elements have to be rendered (but not necessarily visible) in order to reliably access their dimension properties.

So display: none; won't work because the elements are not rendered, and visibility: hidden; will partially work because the elements are rendered, so space is allocated for them on the page, but hidden, so that space will remain empty.

A third solution is to render the container as usual, but make it absolutely positioned outside of the browser viewport:

filterPanel.Attributes.Add("style",
    "position: fixed; left: -10000px; top: -10000px;");

That way, the panel and its contents won't be visible, but the size of the <select> elements will be properly computed.

On the client side, the formula to show the panel becomes:

document.getElementById("filterPanelClientID").style.position = "static";

And to hide it again:

document.getElementById("filterPanelClientID").style.position = "fixed";

You can test a jQuery-based implementation here.

梨涡少年 2024-10-21 00:14:07

问题是,如果您在服务器控件上设置 Visible="false",它将不会呈现任何 HTML 元素,包括组合框。使用以下方法隐藏面板是 AJAX 友好的:

<asp:Panel id="p" runat="server" style="display:none">

</asp:Panel>

它将呈现一个 DIV 和所有下拉菜单,但将它们隐藏在视图中,从而允许您切换 div 的可见性。

The issue is that if you set Visible="false" on a server control, it won't render any of the HTML elements, including the combo boxes. Hiding the panel using the following is AJAX friendly:

<asp:Panel id="p" runat="server" style="display:none">

</asp:Panel>

Which will render a DIV and all your drop downs, but hide them from view, allowing you to toggle the div's visibility.

骑趴 2024-10-21 00:14:07

不要将“display:none”应用于面板,仅应用“visibility:hidden”:

filterpanel.Attributes.Add("style", "visibilty: hidden");

这将隐藏您的面板(我想是

),但保留所需的空间(因此将允许相应 DOM 元素的维度相关属性具有正确的值)。

当然,您会看到一个空位,但您可能可以通过使用元素的样式来解决此问题(也许可以通过将面板嵌套在另一个元素内并将样式应用于该元素,而不是在面板本身上执行此操作)。

Don't apply the "display: none" to the panel, only "visibility: hidden":

filterpanel.Attributes.Add("style", "visibilty: hidden");

This will hide your panel (the <div> I suppose) but reserve the required space (and therefore will allow the dimension-related properties of the corresponding DOM element to have the right values).

Of course you'll see an empty spot but you could probably resolve this issue by playing with the styles of an element (maybe by nesting the panel inside another element and by applying styles to that element instead of doing that on the panel itself).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文