Reputation: 33
I am using an update panel inside a user control in ASP.NET (.ascx file). Below is my HTML markup
<asp:ScriptManager EnablePartialRendering="true"
ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" >
<ContentTemplate>
<asp:Label ID="Label1" runat="server" /><br />
<asp:Button ID="Button1" runat="server" Text="Update Panel" OnClick="Button1_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
here is my code-behind
public partial class sample: System.Web.UI.Control
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToLongTimeString();
UpdatePanel1.Update();
}
}
If I use PostBackTrigger, then it works fine but posts back the entire page (that's something I don't want) I just need to refresh the update panel.
And here is my aspx page markup (it's Sitecore driven site so all the sublayouts are loaded into Sitecore placeholders)
<form id="form2" runat="server">
<section class="page">
<sc:Placeholder runat="server" ID="mainPlaceholder" Key="content" />
</section>
</form>
I'm sorry, cannot post the entire page due to some security reasons
Thank you
Upvotes: 1
Views: 2454
Reputation: 33
Finally, I found a solution to fix this issue. My entire HTML markup remains same just need to comment or take off the triggers. I just commented the inner HTML of tag and it everything worked as expected.
Upvotes: 1
Reputation: 5068
a few things to try. (it works fine for me.)
you are also setting some properties that are equal to the default values so you can remove them:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" /><br />
<asp:Button ID="Button1" runat="server" Text="Update Panel"
OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToLongTimeString();
//UpdatePanel1.Update();
}
Upvotes: 0