.net 手风琴给我带来了问题

发布于 2024-07-11 17:20:06 字数 1724 浏览 4 评论 0原文

我有一堆根据网页中的操作显示、隐藏、启用和禁用的控件。 一切正常,直到我把它们放入手风琴中。 现在我无法让 Javascript 更新它们的状态。 我有一个小例子,

这是 Javascript

 <script type="text/javascript">
  var ctrl = document.getElementById('<%= btmRocp.ClientID %>');

    function ShowPanel(control)
{
    alert('<%= btmRocp.ClientID %>');
    ctrl.disabled = true;
}
</script>   

这是 Accordian

 <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:Accordion  ID="MyAccordion"
                        runat="Server"
                        SelectedIndex="0"                      
                       >
         <Panes>
            <cc1:AccordionPane ID="accordianPane0" runat=server>
            <Header>Create New Report </Header>
            <Content>a
            <asp:Button ID="Button1"  onmouseup="ShowPanel('') " runat="server" Text="Button" />            
            <asp:Button ID="btmRocp" runat="server" Text="Button" />
            </Content>
            </cc1:AccordionPane>
            <cc1:AccordionPane ID="accordianPane1"  runat=server>
            <Header>Create New Report </Header>
            <Content>b</Content>
            </cc1:AccordionPane> 
            </Panes>

        </cc1:Accordion>

我很想知道我在这里做错了什么,警报打印出正确的 ID。

如果我做某事,将“this”对象传递给函数,我可以禁用该按钮,但我确实需要它来禁用或隐藏 10 个对象

有人知道吗?

示例代码位于 http://www.riconllc.com/accordian.zip

I had a bunch of controls that I displayed, hid, enabled and disabled based on actions in the web page. Everything worked until i put them into an accordian. Now I can't get the Javascript to be able to update their state. I have a small example

this is the Javascript

 <script type="text/javascript">
  var ctrl = document.getElementById('<%= btmRocp.ClientID %>');

    function ShowPanel(control)
{
    alert('<%= btmRocp.ClientID %>');
    ctrl.disabled = true;
}
</script>   

This is the Accordian

 <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:Accordion  ID="MyAccordion"
                        runat="Server"
                        SelectedIndex="0"                      
                       >
         <Panes>
            <cc1:AccordionPane ID="accordianPane0" runat=server>
            <Header>Create New Report </Header>
            <Content>a
            <asp:Button ID="Button1"  onmouseup="ShowPanel('') " runat="server" Text="Button" />            
            <asp:Button ID="btmRocp" runat="server" Text="Button" />
            </Content>
            </cc1:AccordionPane>
            <cc1:AccordionPane ID="accordianPane1"  runat=server>
            <Header>Create New Report </Header>
            <Content>b</Content>
            </cc1:AccordionPane> 
            </Panes>

        </cc1:Accordion>

I would love to know what i am doing wrong here the Alert prints out the right ID.

If i do something where i pass the "this" Object to the function i can disable that button but I truly need it to disable, or hide like 10 objects

Does anyone have an idea?

Sample Code at http://www.riconllc.com/accordian.zip

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

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

发布评论

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

评论(1

左秋 2024-07-18 17:20:06

Accordion 的默认状态是什么? 崩溃了? 我不知道 Accordion 是如何工作的,但我怀疑它正在修改 HTML DOM,这样当页面首次加载时,“btmRocp”实际上并不存在于页面本身上,直到它变得“可见”。 也就是说,它可能根据手风琴状态将控件注入页面或从页面注入控件。

弄清楚这种行为的最佳选择是插入“debugger;” 在适当的时间点将语句添加到页面中,以便在这些时间点检查实时 DOM。

<textbox id="debugbox" onblur="this.value = eval(this.value);"></textbox>

这也是在页面上使用脚本的好方法。

What is the default state of the Accordion? collapsed? I have no idea how the Accordion works, but I'm suspecting that it is modifying the HTML DOM such that when the page first loads "btmRocp" is not actually present on the page itself, until it becomes "visible". That is, it might be injecting controls into and out of the page, based on the accordion status.

Your best bet in figuring out this behavior is to insert "debugger;" statements into your page at appropriate points, to inspect the live DOM at those points in time.

<textbox id="debugbox" onblur="this.value = eval(this.value);"></textbox>

Is a good way to monkey with script on your page as well.

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