This question is an extension to http://stackoverflow.com/questions/920384/showing-hiding-div.
As stated, I found a workaround to prevent a Collapse panel from flashing upon load.
My solution was this:
In header:
function showDivs() {
divMenuContent.style.visibility = 'visible';
divMenuContent.style.display='block';
}
</script>
and panel hidden in div as:
<div id="divMenuContent" style="visibility:hidden; display:none;">
<asp:Panel ID="pnlAddNewContent" runat="server" CssClass="collapsePanel" Width="500px">
</asp:Panel>
</div>
and body load is onLoad="javascript:showDivs();"
The thing is, it works perfectly on a blank page. But I think when I do a
ClientScript.RegisterClientScriptBlock(this.GetType(), "", sb.ToString());
it doesn't work - as in the panel doesnt collapse/show. The above code does work.
Do you believe the clientScipt conflicts with my javascript to show div? I don't receive any Javascript run errors within browser.
More info: The clientScript is called if its not a postback. I have also tried to call the javascript from the clientscript by adding the following code at the end of it:
sb.Append("\n}\nshowDivs();</script>\n");
But this time I get the following error:
divMenuConent is undefined.
ANy solutions?