BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
Latest Game

Reusing ascx web controls

by Benjamin Nitschke 11. April 2007 20:50
After developing and testing some ascx web controls in the past I was woundering why I have to copy them over to a new web project today instead of just referencing them. When you write a normal windows application and then want to reuse some library parts in another project (or if you just want to structurize your app a little bit better) you would obviously use a dll library for the job to share functionality.

Not that easy with web controls. My first thought was just to copy the .ascx and .ascx.cs files over to a new dll project and start compiling. After adding the missing images and scripts the following thing happend:



Well, the code does compile on a website, but in a dll project it will not build the ascx code for you and merge the controls defined there with your .cs file. If you do not define controls or do any visual stuff you can probably just use WebControls instead of UserControls, but you still have to implement the Render method yourself and you just do not have any design support. More information about creating server controls can be found here.

While that solution is probably the cleanest one and has the advantage of hidding the source code and make it easy to just drag and drop controls on your page, it is the hardest to develop. And I already have my .ascx controls working, I just want them in another project without copying them over again and again.

I searched for a while on the web for some solutions, see below for all the links. The best solution for me was the one from ScottGu, which just uses a normal website and then uses a post build copy to get all the files into your current website project. The controls dummy website can then be used all over the place, you just have to add the copy command to each website that should use your controls. This solution might not be the best, so if you have more complex problems, check out the links below.

No reason to repeat all the stuff ScottGu has already written, check out his great article here or here.

BTW: I use this just for simpler web controls or when I have something that needs to be duplicated on some pages. For Ajax controls on the other hand I got a project similar to the AjaxControlToolkit, but there you live without design time editors anyway.

Links:

Comments


4/18/2010 1:28:17 PM #

Some facts in this article are really true and very useful in life.

us | Reply



4/18/2010 5:35:49 PM #

Excellent blog post, I look forward to reading more.

us | Reply



4/27/2010 10:16:09 PM #

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare | Reply



5/4/2010 4:57:33 PM #

Top Rapidshare Search engine

Rapidshare Search engine | Reply



5/5/2010 10:24:42 AM #

Wow! what an idea ! What a concept ! Beautiful .. Amazing ?

cep oyun indir | Reply



5/12/2010 6:35:29 PM #

First of all thanks a lot for the informative and useful information. I have just been searching for some information about the ascx web controls and accidentally I have noticed this your entry. Well, this website is really great and full of various and attractive information about everything. Thanks a lot one more time for the great and informative article and keep up publishing these great posts in the future too.

installment loans no credit check | Reply



5/14/2010 6:17:34 PM #

Your website is really useful for many people I think. You helped  me in various situations because I many times I have found the useful information which was really important for me in your site. Reading this your post I have known many new things about the  ascx web controls which I have not known before. It is really great that you share for us such useful stuff. Thanks a lot one more time for the useful information and I will be waiting for more great news from you in the nearest future.

extended auto warranty advantages | Reply


Add comment




biuquote
  • Comment
  • Preview
Loading



Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2010 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

Recent Games

Fireburst

ArenaWars Reloaded

Jobs @ exDream

Current Poll

Do you know what the Delta Engine is?



Show Results Poll Archive

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

Blogs

Download OPML file OPML