In .Net 1.x you can dynamically load user controls using the Page.LoadControl member. Providing you namespace your classes the same or qualify the classes correctly you can cast the return value of LoadControl to an object of your user control type.
MyUserControl myUserControl = (MyUserControl )LoadControl(“MyUserControl.ascx”);
MyFolderedUserControl myFolderedUserControl = (MyFolderedUserControl )LoadControl(“Folder/MyUserControl.ascx”);
Moving to .Net 2.0, where namespaces are no longer a key reference mechanism, an additional step is required.
In the partial code behind class, specify the loading and casting as you would in Net 1.x.
MyUserControl myUserControl = (MyUserControl)LoadControl(“MyUserControl.ascx”);
MyFolderedUserControl myFolderedUserControl = (MyFolderedUserControl)LoadControl(“Folder/MyUserControl.ascx”);
However, when you attempt to compile this code, the second line will fail, this is because the foldered user control is not part of the main assembly and the compiler knows nothing about it. To fix this you need to add a reference attribute to the aspx file that will host the user control:
<%@ Reference Control="Folder/MyUserControl.ascx" %>
Introduction to Data Wrangler in Microsoft Fabric
What is Data Wrangler? A key selling point of Microsoft Fabric is the Data Science
Jul
Autogen Power BI Model in Tabular Editor
In the realm of business intelligence, Power BI has emerged as a powerful tool for
Jul
Microsoft Healthcare Accelerator for Fabric
Microsoft released the Healthcare Data Solutions in Microsoft Fabric in Q1 2024. It was introduced
Jul
Unlock the Power of Colour: Make Your Power BI Reports Pop
Colour is a powerful visual tool that can enhance the appeal and readability of your
Jul
Python vs. PySpark: Navigating Data Analytics in Databricks – Part 2
Part 2: Exploring Advanced Functionalities in Databricks Welcome back to our Databricks journey! In this
May
GPT-4 with Vision vs Custom Vision in Anomaly Detection
Businesses today are generating data at an unprecedented rate. Automated processing of data is essential
May
Exploring DALL·E Capabilities
What is DALL·E? DALL·E is text-to-image generation system developed by OpenAI using deep learning methodologies.
May
Using Copilot Studio to Develop a HR Policy Bot
The next addition to Microsoft’s generative AI and large language model tools is Microsoft Copilot
Apr