Some situation comes into picture where we want to change the web page to User control.
Steps to convert asp.net web page to user control.
- Rename to the file extenstion (.aspx) to a .ascx extension.
- Remove html, head, body, form tags from the page.
- Change the "@ Page" directive to a "@ Control" directive.
- Remove all attributes of the "@ Control" directive, except Language, AutoEventWireup, CodeFile, and Inherits.
- Need to change the Inherits to have your new UserControl code behind file's name.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UserControlFilename.ascx.cs" Inherits="UserControlFileName" %> - Close and re-open the file to make squiggles go away.
- Open the code behind file and change the class it inherits from to UserControl, and the class name to match your .ascx file.
public partial class UserControlFileName : System.Web.UI.UserControl
Hope this helps for some body.
0 Comments:
Post a Comment