Create a WebControl in the CodeBehind

J

jay

Greetings

ASP.NET 2.0

I'm developing a webcontrol. The class will ultimately end up in a
webcontrols DLL, but for development purposes, I want to put the class
in a code-behind. This is so that I can work on the class without
recompiling and deploying a DLL, and waiting for the website to
recompile. The website takes a long time to load after a recompile. I'm
trying to avoid that delay. Making my changes in the code behind
accomplishes that.

public partial class TestPage_aspx : Page
{
....
}

namespace howdy {
public class TestControl : WebControl
{
....
}
}

Initially, I put a place holder on the page, then created an instance
of TestControl and added it to the place holder. Now that I'm dealing
with the postbacks, etc, I'd rather do it declaratively.

<whatever:TestControl ID="tester" runat="server"/>

I'm having trouble registering the control on the page, though.

<%@ Register Namespace="howdy" Assembly="???" TagPrefix="whatever" %>

If that's the proper way to do it, what should I enter for Assembly? (I
think it would be APP_CODE if I put it in the app_code folder, but that
too causes a recompile, so I'm avoiding it).
 
G

Guest

Aye, that's the Catch-22 isn't it?
What I would consider doing is to switch over to the new Web Application
project model, and have your control as a project within the solution. Then,
after it's deployed, all you need to do is build the newest version of your
control and copy over it's assembly to the bin folder of your site. Presto!
No Recompilations.
Peter
 
J

jay

Peter said:
Aye, that's the Catch-22 isn't it?
What I would consider doing is to switch over to the new Web Application
project model, and have your control as a project within the solution. Then,
after it's deployed, all you need to do is build the newest version of your
control and copy over it's assembly to the bin folder of your site. Presto!
No Recompilations.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
J

jay

My first response didn't make it through.

Anyway...

Thanks for the information, but that's not quite what I'm looking for.
Currently the class is in a separate project. Each time I recompile the
project, it is copied to the bin folder. Each time it is copied to the
bin folder, the web app restarts. There's then a huge delay as it
starts up. Once the delay is over, I log back in and go to my page.

If we can get this to work in the code behind, simply refreshing the
page works. It only recompiles the one page. This worked great when i
manually added the control and got me most of the way through.

Perhaps I should have said I want to avoid recompiles and restarts.

Thanks for your help.

Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top