Keeping Dynamic Controls Dynamic

Part of the issue with including User Controls in a page by adding them in the top of the page like this:

<%

@ Register TagPrefix="HMD" TagName="Assortment" Src="~/Controls/assortments.ascx" %>
is that if the content is something like say a shopping cart or dropdownlists generated from a database or something where the state and the refreshed load is terribly important  - a solution is to load the control dynamically based on an event.  Dim the control and add it to the page via a literal or panel or table cell or some other object that could house it.  This assures that the control is loaded fresh everytime it needs to be.

Dim ctlStoreSku As Control = LoadControl("controls/skuweekly.ascx")

myPanel.Controls.Add(ctlStoreSku)

myPanel.Visible =

True
That's  it....

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax