Using an Updatepanel in a Usercontrol for you ASP.Net Website

September 13, 2012

Normally putting controls into an ascx file in your website is a great way to make your code easier to digest. Especially on some pages that can have some thousands of lines of code. It helps to keep your sanity at times. And use the search function less.
However I recently ran into an issue where my usercontrol had an updatepanel in it. It would seem that dynamic loading of the control, while convenient, was not the right way to do things. For whatever reason MS requires you to take a few additional steps.
It would seem that to get partial page updates on your control the attribute UpdateMode=”Conditional” is required. Let me show you.
<% @ Register TagPrefix=”my” TagName=”AddEntity” Src=”~/UserControls/PropertyViewAddEntity.ascx” %>

Above is my register of the control.

< my:AddEntity Visible=”false” ID=”test1″ runat=”server” ClientIDMode=”Inherit” UpdateMode=”Conditional” />

And above is where my placeholder for the control. As you can see there is the updatemode attribute. As soon as I did this everything worked like it should. And I had partial page rendering.

Got something to say?

You must be logged in to post a comment.