5,530,111 members and growing! (16,720 online)
Email Password   helpLost your password?
Web Development » User Controls » General     Intermediate

ASCX Control Parser

By Ben van Klinken

A program that allows you to convert .ascx User Controls into redistributable controls
C#, Windows, .NET 1.0, .NET, ASP.NET, Visual Studio, VS.NET2002, Dev

Posted: 23 Apr 2002
Updated: 23 Apr 2002
Views: 72,320
Bookmarked: 46 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 3.71 Rating: 4.11 out of 5
1 vote, 16.7%
1
1 vote, 16.7%
2
0 votes, 0.0%
3
2 votes, 33.3%
4
2 votes, 33.3%
5

Introduction

Have you ever wanted to turn a .ASCX file into a distributable control? This program generates the source code for an .ASCX file so that you can compile it without having to distribute the .ASCX file. It comes close to simulating how the Page.LoadControl ("asdf.ascx") works.

Usage:

  • Run the exe file, paste in the ascx code into the textbox.
  • Choose the output class name (it will be created in the ASP namespace - but you can change this manually)
  • The "Has base class?" checkbox sets the parser to declare the controls or not. If this is ticked then the base class should have declared each control already.
  • Click go, and the C# code will be outputted in the same textbox.
  • Put the code into a new class in a web application and hopefully it should compile.
  • To add the code to a page you would do this (Assuming that the class was called CDefault and the namespace was left as ASP):
    //=======================================================
    
    private void Page_Load(object sender, System.EventArgs e)
    {
     // Put user code to initialize the page here
    
     Control c = new ASP.CDefault();
     this.Controls.Add ( C );
    }
    //=======================================================
    
    

Known issues: 

  • Compiler directives are ignored so registering controls other than asp controls (asp: namespace) must be done manually. You may have to do some editing on the output to suit your needs (such as code-behind class, etc).

  • List properties are not loaded properly. For example, the property Font-Names on a label control is actually a string list (string[]). The parser can't tell if a property is a list because it can't always do reflection on the type (any ideas how to fix this?).

TODO:

  • Add a VB.NET output, currently the output is only written for C#.
  • Make it a Visual Studio Add-In.
  • Recognise compiler directives.

Registration

If you like it, please send an email to bvk@villagechief.com

If you make any changes or additions, please send them to me at the above email address.

Copyright and License

This is freeware to do with as you see fit. The author accepts no responsibility for any damage or data loss caused by this program.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Ben van Klinken



Location: United States United States

Other popular User Controls articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 6 of 6 (Total in Forum: 6) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralhmmmmemberLawrence Botley11:03 13 Nov '06  
GeneralRe: hmmmmemberkelasings16:30 15 Sep '07  
QuestionRe: hmmmmemberstixoffire7:59 5 May '08  
GeneralRe: hmmmmemberstixoffire8:29 5 May '08  
GeneralQuick Update with VBmemberTodd77777716:51 22 Feb '06  
Generalnice projectmemberSteve McLenithan11:22 8 Oct '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 23 Apr 2002
Editor: Chris Maunder
Copyright 2002 by Ben van Klinken
Everything else Copyright © CodeProject, 1999-2008
Web07 | Advertise on the Code Project