473,591 Members | 2,797 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a WebControl in the CodeBehind

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:TestC ontrol ID="tester" runat="server"/>

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

<%@ Register Namespace="howd y" Assembly="???" TagPrefix="what ever" %>

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).

Nov 10 '06 #1
4 3589
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


"ja*@allardwork s.com" wrote:
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:TestC ontrol ID="tester" runat="server"/>

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

<%@ Register Namespace="howd y" Assembly="???" TagPrefix="what ever" %>

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).

Nov 10 '06 #2
jay

Peter wrote:
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


"ja*@allardwork s.com" wrote:
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:TestC ontrol ID="tester" runat="server"/>

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

<%@ Register Namespace="howd y" Assembly="???" TagPrefix="what ever" %>

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).
Nov 10 '06 #3
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
Peter wrote:
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


"ja*@allardwork s.com" wrote:
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:TestC ontrol ID="tester" runat="server"/>

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

<%@ Register Namespace="howd y" Assembly="???" TagPrefix="what ever" %>

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).
Nov 10 '06 #4
Yeah, no way to avoid that because of the way ASP.NET monitors files and the
bin folder. However, as a single assembly WAP project I bet it would restart
faster.
Peter

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


"ja*@allardwork s.com" wrote:
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
Peter wrote:
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


"ja*@allardwork s.com" wrote:
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:TestC ontrol ID="tester" runat="server"/>
>
I'm having trouble registering the control on the page, though.
>
<%@ Register Namespace="howd y" Assembly="???" TagPrefix="what ever" %>
>
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).
>
>

Nov 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1685
by: davidw | last post by:
As I asked in last post, I want to put some logic in a object and all my webcontrol instance will access that object, the object is responsed to retrieve data from database if the data has not been retrieved yet. Vadym Stetsyak suggested me to use singleton, it seems a good solution for me, but after I read more about singleton, I find another issue - if I use singleton patter, I can not store context data in the class anymore. How I used...
2
5909
by: Novice | last post by:
I can't seem to get my Custom WebControl to output a button whose click event is associated with a particular method. Here is the code I have right now that contains a panel and there is a button in that panel that should be associated with a event method - but it isn't working: protected override void Render(HtmlTextWriter output) { Panel panel = new Panel(); nextButton = new Button();
13
8851
by: Daniel Walzenbach | last post by:
Hi, Imagine the following situation: I have an asp.net application which allows uploading files to a SQL Server 2000 database (Files are stored as type "images"). As a next step I would like to implement some way to enable downloading those files from the database which leads me to the following two problems: 1.) How can I create a file "in memory" as I don't want to create temporary files stored on my web server and
4
2155
by: jesper_lofgren | last post by:
Hi there, I have some webcontrols that i want to add dynamically on a page. I have stored the path / namespace in database (ex MyNameSpace.WebControls.Control1) to the class/webcontrol. Lets say i have a column in database that looks like this. PageID (int) Webcontrol (varchar) 1 MyNameSpace.WebControls.Control1
4
1328
by: Cesar Ronchese | last post by:
Hello. I have a WebForm that contains a Panel object. This panel, at design time is empty. When running, I need to create dinamically a Label and a WebControl (built from the same project). I can create the label and the webcontrol dinamically with no errors, but only the Label appear in the panel when the page is shown in the client browser.
0
1627
by: Jose Fernandez | last post by:
Hello First of all, excuse my english We all know that in a normal page with codebehind we add a dropdownlist control and we bind() it in the (!ISPOSTBACK), so, we don't need to go to database again 'cause its value are saved (i assume viewstate). Well. I have a class that inherits from WebControl and INamingContainer. This class Load an ASCX control (that contains other controls in itself like textbox and Dropdownlist). In the...
6
2519
by: Dave Harvey | last post by:
I have developed a standard .NET control which displays medical images and works fine in applications, but increasingly, my customers are wishing to use it in an ASP.NET environment, so I am looking to make a WebControl based equivalent. So, assuming that I need to render using HTML - how can I pass "bitmap" data into such a control for it to be displayed. I'm open to all possible routes, but I've not yet found one which works. Ideas...
0
1606
by: Vaibhav Shah | last post by:
Hi, While loading a user control with IE WebControl's tree view in it, on a webpart, i am getting this error. Error: unable to load ~\UserControls\TreeViewControl.ascx Details: Parser Error: Could not load type Microsoft.Web.UI.WebControls.Design.CssCollectionEditor from assembly mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
6
6437
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data) and be able to load them to an image webcontrol, but system.web.ui.webcontrols.image only seems to have a control to load the image from a URL. There's no way to load this directly without saving the image as a file and then using...
0
7934
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7870
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8236
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7992
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8225
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5400
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3891
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1465
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.