aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT, Building Your First Web Application Project
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Monday, December 13, 2010 Total Views:  

In this example i have told you how to load web user control dynamically in your ASP.NET web form. ASP.NET have .aspx file extension where as web user control have the .ascx file. In this example, i have assumed that you know, how to create a web user control.

Here’s is the solution

C#

   protected void Page_Load(object sender, EventArgs e)
   {
       Control userControl = Page.LoadControl("WebUserControl.ascx");
       Page.Form.Controls.Add(userControl);
   }

VB.NET

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       Dim userControl As Control =
       Page.LoadControl("WebUserControl.ascx")
       Page.Form.Controls.Add(userControl)
   End Sub

Download

LoadControl.zip (1.93 kb)

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5