Monday 11 February 2013

Create Assembly from user controls(Web User Control in an assembly )


In order to create Assembly from user controls , please follw the below steps:

our assembly name is (Amer.UserControlsLibrary).



1.Create web application using vs2008 or vs 2005 and name it (Amer.UserControlsLibrary).



2.delete Default.aspx and Web.config from (Amer.UserControlsLibrary) application



3.Add new web user control and name it (Login.ascx).

if you look at html code you will see

<%@ Control Language="C#" AutoEventWireup="true"

CodeBehind="Login.ascx.cs" Inherits="Amer.UserControlsLibrary.Login" %>


and if you look at code behined you will see the name space

namespace Amer.UserControlsLibrary



4.change the CodeBehind attribute name to ClassName then add CodeFile="Login.ascx.cs" to step 3.

to get new user control directive like this :

<%@ Control Language="C#" AutoEventWireup="true"

CodeFile="Login.ascx.cs" Inherits="Amer.UserControlsLibrary.UICode.Login"

ClassName="Amer.UserControlsLibrary.UI.Login" %>.



please note from step 4 that

CodeFile="Login.ascx.cs"

ClassName="Amer.UserControlsLibrary.UI.Login"

Inherits="Amer.UserControlsLibrary.UICode.Login"





5.Create New Web User Control and name it UserProfile.ascx and make sure the user control directive is

<%@ Control Language="C#" AutoEventWireup="true"

CodeFile="UserProfile.ascx.cs"

Inherits="Amer.UserControlsLibrary.UICode.UserProfile"

ClassName="Amer.UserControlsLibrary.UI.UserProfile" %>





6.

No comments:

Post a Comment