PDA

View Full Version : Change coolite control state while in UpdatePanel async postback



omeriko9
May 03, 2008, 5:36 PM
Suggesting the following code:



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="Coolite.Web.UI" Namespace="Coolite.Web.UI" TagPrefix="cool" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script language="CS" runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text += "A ";
Label2.Text += Label1.Text;
UpdatePanel2.Update();
}
protected void Button2_Click(object sender, EventArgs e)
{
FieldSet1.Collapsed = false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<cool:ScriptManager ID="ScriptManager2" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button1" />
<cool:Panel ID="Panel1" runat="server">
<Content>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Height="30px" Text="Label" Width="61px"></asp:Label>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button2" CausesValidation="False" />
</ContentTemplate>
</asp:UpdatePanel>
<cool:FieldSet ID="FieldSet1" runat="server" Collapsible="True" Width="200px" Collapsed="True">
<Content>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server" Height="35px" Text="Label" Width="78px"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</Content>
</cool:FieldSet>
</Content>
</cool:Panel>


</form>
</body>
</html>



How can I make Button2 (nested in an UpdatePanel) expand (uncollapse) FieldSet1 from code behind?

geoffrey.mcgill
Jun 04, 2008, 10:28 PM
Hi omeriko9,

With the latest version 0.5 build, I think your sample will work with one small modification... you should call the .Collapse() method on FieldSet1.

Example


protected void Button2_Click(object sender, EventArgs e)
{
this.FieldSet1.Collapse();
}

Hope this helps.