Wednesday, August 29, 2012

Difference between ASPX and ASCX

S.No
ASPX
ASCX
1
ASP.NET Page uses the extension .aspx
For eg: Default.aspx
User Control uses the extension .ascx
For eg: WebUserControl.ascx.
2
ASP.NET Page begin with a Page Directive.
For eg:
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default" %>

User Control begin with a Control Directive.
For eg:
<%@ Control Language="C#"
AutoEventWireup="true"
CodeFile="WebUserControl.ascx.cs"
Inherits="WebUserControl" %>

3
Usercontrol code can be used in webforms
We can not use webforms in usercontrol.

4
ASP.NET Page can be viewed directly in the Browser.

User Control cannot be viewed directly in the browser. User Controls are added to WebPages and we view them by requesting a web page in our browser
5
ASP.NET page has HTML, Body or Form element.
User Control does not have a HTML, Body or Form element.

3 comments: