Hopefully I am in the right forum... :)
I am stumbled that I cannot get this little thing to work, been playing around with it for hours now...
My problem:
I have a master page looking like this (more or less)
<asp:Panel ID="Panel1" runat="server" CssClass="ShowHideMenu">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnshow" runat="server" CssClass="mainmenubtn" Text="Show" OnClientClick="showDiv('divtest');" />
<asp:Button ID="btnhide" runat="server" CssClass="mainmenubtn" Text="Hide" OnClientClick="hideDiv('divtest');" />
<div id="divtest" style="display: none;">
Hello World in a DIV, which shall be shown/hidden through a click
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnshow" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnhide" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</asp:Panel>My .JS functions "showDiv" and "hideDiv" looks like this:function hideDiv(divstring) { //Sets display state to "none"
var divdoc = getelement(divstring)
divdoc.style.display = "none";
return false;
}
function showDiv(divstring) //Sets display state to "block"
{
var divdoc = getelement(divstring);
divdoc.style.display = "block";
return false;
}Doing this in a .ASPX file works fine. When I do this in a .master page, it...bugs (not really the master page's fault, its a combination of update-panel + panel....) :)What happens:
I click hide: the "testdiv" is hidden.
I click show: the "testdiv" is shown for a nanosecond, and something is turning the div to hide again.
What I want: Simply just show and hide a simple div, with a <asp:button..> from both outside the update-panel, and from within the update-panel, for a start; just from within the update-panel. :)
The error is this: the "runat="server"" tag at the two buttons, it makes the whole page (even if I use update panel with the tag updatemode=conditional) reload (a postback?)... Well, If I remove runat=server, the buttons do not show.
How can I still use the <asp:button ...> tag, without the "runat="server" attribute? Is that even possible? I mean, if it isn't, why in the blue hell did MS make us write "runat="server"" in the first place, if it is always required...? (Hopefully fixed in VS2010 package! :))
Well, suggestions? :)


Sign In
Create Account


Back to top









