Converting Web Pages to User Controls in .NET

There are instances where you would like to use web page functionality repeatedly within your application and you might want to convert it to a user control so that you can do so. It is easy to convert a web page to a user control with some minor modifications in it.

As you know the user control files have an extension .ascx, you have to change the file extension of the web page to that of .ascx. For this you can use the Rename functionality found in the context menu from the Solution Explorer.

After renaming the file, you have to remove the html, body, and the form tags found in the web page. Now coming to the top of the page, you will have the @page directive. Now change the @page directive to a @control directive.

The attribute like language, AutoEventWireup, CodeFile and Inherits can be left as it is. Add an attribute called className to the @control directive and give a ClassName. Now you are ready to use this user control in the web page of your choice.






______________________________________________________

Recommended Resource



| Converting Web Pages to User Controls in .NET | .Working on .NET User Controls | Overview of ASP.NET User Controls | Web User Controls - Creation and Implementation | Advantages of using User Controls in ASP.NET | Re-usability of User Controls in ASP.NET | Personalizing Web Application by Creating User Controls in .NET | Customizing your Application with VB.net User Controls | Building User Controls in ASP.NET | Examples of User Controls in VB.NET | Example of C# User Controls | Where to use Visual Basic User Controls | Working on User Interface Controls | Creating Dynamic User Controls | Understanding VB .NET User Controls | Creating User Controls VB.NET | How to load user controls dynamically |



_______________

FREE Subscription

Stay Current With the Latest Technology Developments Realted to .NET. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.


 

| Privacy Policy for www.dotnet-guide.com | Disclosure | Contact |

Copyright - © 2004 - 2017 - All Rights Reserved.