Wednesday, March 21, 2012

Partial page rendering of user control

I have a user control. This user control has an update panel in it. Everything works great with the user control.

Now when I include the user control into a .aspx page I have it set up so that after a specific delay in seconds (set by a timer) it loads. But when it loads it causes a complete page refresh. I would like it so that only the area where the control is placed is refreshed.

I thought about wrapping the user control in the .aspx with an update panel but it throws a message of couldn't find a control in the user control. Basically it is a update panel inside of an update panel each mode set as conditional. When I run the user control without the update panel everything works fine.

Anyone have an idea of to go about this. Here is a bit of code:

<

asp:TimerID="timerCalendar"runat="server"OnTick="loadCalendar"Interval="2000"enabled="false"></asp:Timer>
<asp:UpdatePanelid="upCalendar"runat="server"UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTriggerControlID="timerCalendar"eventname="Tick"/>
</Triggers>
<ContentTemplate>
<asp:PlaceHolderID="phCalendar"runat="server"></asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>User control is dynamically loaded and put into the placeholder when the timer is enabled.

thanks ^_^

Have you tried removing the UpdatePanel from the usercontrol... and instead of using a "PlaceHolder" to dynamically add your UserControl to... use an "UpdatePanel" in your page... then instead of "myPlaceHolder.Controls.Add(myUC);" do "myUpdatePanel.Controls.Add(myUC);"?


Good idea. Didn't think of that.

Question though. Within the user control I have a gridview. Would I add a trigger dynamically to the update panel in the page where the user control is dynamically loaded as well and set the trigger id to gridview in the control (do a findcontrol on the control id) or how would I go about getting the gridview to use the update panel as well?

Hope that makes sense. :)


Discovered the solution. I didn't have the mode for each updatepanel to conditional. Once I did this everything worked just fine. :)

No comments:

Post a Comment