Hi everyone. I think I need some help. I've been having problems with my update panel not updating when I change for instance a label within the update panel from a server-side button eventhandler. I've spent hours testing different things with updatemode, childrenastriggers etc., and what have you, but nothing I do seems to work. So I will post some code and maybe this is obvious to some of you what I am missing, I hope!
I am wondering if it is my collapsible panels that cause some issues? Otherwis if I remove the updatepanel
it works but I would prefer if I don't have to use a postback.
Also I tried wrappen the whole thing in the updatepanel. That is all the panels inside the updatepanel but it
doesn't work either.
Ideas?
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="~/Styles/Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Panel ID="TitlePanel" runat="server" CssClass="collapsePanelHeader">
<asp:Image ID="imgBtn" ImageUrl="~/Images/edit.png" runat="server" />
<asp:Label ID="lblTitle" Text="Title" runat="server"></asp:Label>
</asp:Panel>
<asp:Panel ID="ContentPanel" runat="server" CssClass="collapsePanelContent">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lbl" runat="server" Text="start text"></asp:Label>
<asp:Label ID="lblContent" Text="Content" runat="server"></asp:Label>
<asp:Button ID="btnContent" Text="Lägg till" runat="server" OnClick="btnContent_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpe"
runat="server"
TargetControlID="ContentPanel"
ExpandControlID="TitlePanel"
CollapseControlID="TitlePanel"
ExpandedText=""
CollapsedText=""
CollapsedImage="~/Images/edit.png"
ImageControlID="imgBtn"
EnableViewState="true"
Collapsed="true">
</asp:CollapsiblePanelExtender>
</div>
</form>
</body>
</html>
And the code-behind: It only changes the text of a label right now but I just want the update to work.
The event fires ok when I debug so that's not it. And I have already tried updatemode="always" and
it doesn't update automatically when I remove the this.UpdatePanel1.Update()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class My_CollapsiblePanels : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Response.Write("postback");
}
}
protected void btnContent_Click(object sender, EventArgs e)
{
lbl.Text = "lorum ipsum seclorum";
this.UpdatePanel1.Update();
}
}
↧
UpdatePanel not updating itself problem
↧