Home » Asp.netRSS

adding windows user control in asp.net application

hi fri i had created one user control in c# and i want to add this user control in asp.net application pl tel me how to do this

thanks in advance


1 Answer Found


Answer 1

You need to register your UserControl in the page where you are consuming it as per the following:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <form id="form1" runat="server">
        <uc1:WebUserControl ID="WebUserControl1" runat="server" />

Or if you want to load it dynamically use the following:

<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>


Control ctrl = LoadControl("UserControlPath");


Please read the following articles:




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter