.net Accordion causing problems
I had a bunch of controls that I was showing, hiding, enabling and disabling based on actions on a web page. Everything worked until I put them in an accordion. Now I cannot get Javascript to update its state. I have a small example
this is Javascript
<script type="text/javascript">
var ctrl = document.getElementById('<%= btmRocp.ClientID %>');
function ShowPanel(control)
{
alert('<%= btmRocp.ClientID %>');
ctrl.disabled = true;
}
</script>
This is 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 like to know what I am doing wrong here, Alert is printing the correct ID.
If I do something when I pass the "this" object to the function, I can disable that button, but I really need to disable or hide it as 10 objects
Does anyone have any ideas?
Sample code http://www.riconllc.com/accordian.zip
source to share
What is the default state of the Accordion? collapsed? I don't know how the Accordion works, but I suspect it modifies the HTML DOM in such a way that when the page first loads "btmRocp" it is not actually present on the page itself until it is "visible". That is, it can inject controls into and out of the page based on the status of the accordion.
Your best bet when defining this behavior is to insert a "debugger"; statements to your page at the appropriate points to check the current DOM at those points in time.
<textbox id="debugbox" onblur="this.value = eval(this.value);"></textbox>
Nice monkey way with a script in your page.
source to share