473,326 Members | 2,108 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

User Controls not showing in ASP.NET page (described fully in msg)

I have been experimenting with placing user controls (using Windows
Forms controls) into an ASP.NET webpage - and am completely stuck. I
can get a blank user control to work, but nothing beyond that. I have
tried making a very basic test rig to isolate the problem, and have
illustrated it below. For reference, this is using .NET 2 and Visual
Studio 2005.

Here's what I did - the first few steps explain what worked, then what
I did that broke it. If anybody can see the obvious thing I'm missing,
I'd love to hear from you.
1. Create a new "Control Library" solution - call it
"UserControlTestRig"
2. Modify the background color of the default control (UserControl1)
3. Compile, and test. The user control debug form pops up, and it works
fine.

4. Add a new ASP.NET website to the solution
5. Copy the compiled DLL of the user control to the root dir of the
website
6. Refresh the explorer in Visual Studio (to stop it complaining
further on)
7. Add the following to the default.aspx page...
<object id="uc1"
classid="UserControlTestRig.dll#UserControlTestRig .UserControl1">
</object>
8. Run the webpage - it appears, as does the user control with it's
background
color as set when we built it.

All is fine so far. Next I do the following, and have no idea why it
breaks...

9. Edit UserControl1 - add a label control to it (from the standard
windows form
controls)
10. Recompile UserControl1, and copy the DLL over to the web page.
11. Re-open the webpage, to see the usercontrol with the label...
*The control no longer works.*

What's more, once the control is broken, you can't then recompile
without the label, re-copy, and run the webpage again...

If somebody can explain why this is happening I'd love to know.

The maddening thing is I have a fairly complex series of controls that
this happened to this morning, and have spent all afternoon slowly
going backwards until I got to this example - at which point I held my
hands up and said "I'm going to ask on the internet"...

Jul 4 '06 #1
3 2069
I'm getting somewhere with this now - but still don't know why the
problem is occurring (almost certainly my ignorance).

The user control fails to appear in the webpage if it is re-compiled
and replaced in the web root.

This leads me to suspect that the web server is caching something about
the version of the user control the first time it is used, and holding
on to that information.

There must be a configuration setting on the user control (or the
website) to stop it hanging on to the first version it sees - I just
don't know how to do that.

Anybody know how to do that? (make the website ignore the version of
the user control object it's feeding) ?
Jonathan

jo**************@gmail.com wrote:
I have been experimenting with placing user controls (using Windows
Forms controls) into an ASP.NET webpage - and am completely stuck. I
can get a blank user control to work, but nothing beyond that. I have
tried making a very basic test rig to isolate the problem, and have
illustrated it below. For reference, this is using .NET 2 and Visual
Studio 2005.

Here's what I did - the first few steps explain what worked, then what
I did that broke it. If anybody can see the obvious thing I'm missing,
I'd love to hear from you.
1. Create a new "Control Library" solution - call it
"UserControlTestRig"
2. Modify the background color of the default control (UserControl1)
3. Compile, and test. The user control debug form pops up, and it works
fine.

4. Add a new ASP.NET website to the solution
5. Copy the compiled DLL of the user control to the root dir of the
website
6. Refresh the explorer in Visual Studio (to stop it complaining
further on)
7. Add the following to the default.aspx page...
<object id="uc1"
classid="UserControlTestRig.dll#UserControlTestRig .UserControl1">
</object>
8. Run the webpage - it appears, as does the user control with it's
background
color as set when we built it.

All is fine so far. Next I do the following, and have no idea why it
breaks...

9. Edit UserControl1 - add a label control to it (from the standard
windows form
controls)
10. Recompile UserControl1, and copy the DLL over to the web page.
11. Re-open the webpage, to see the usercontrol with the label...
*The control no longer works.*

What's more, once the control is broken, you can't then recompile
without the label, re-copy, and run the webpage again...

If somebody can explain why this is happening I'd love to know.

The maddening thing is I have a fairly complex series of controls that
this happened to this morning, and have spent all afternoon slowly
going backwards until I got to this example - at which point I held my
hands up and said "I'm going to ask on the internet"...
Jul 4 '06 #2
I found *a* solution to it late last night.

The behaviour (recompiled user controls vanishing) only occurs in the
Visual Studio 2005 web server. If you create an IIS website and put the
compiled user control there, it works.

Therefore (at this time) I can only deduce that the problem - if it is
a problem - exists with the mini webserver built into VS2005.

Hope this helps somebody else one day...
jonathan.beckett wrote:
I'm getting somewhere with this now - but still don't know why the
problem is occurring (almost certainly my ignorance).

The user control fails to appear in the webpage if it is re-compiled
and replaced in the web root.

This leads me to suspect that the web server is caching something about
the version of the user control the first time it is used, and holding
on to that information.

There must be a configuration setting on the user control (or the
website) to stop it hanging on to the first version it sees - I just
don't know how to do that.

Anybody know how to do that? (make the website ignore the version of
the user control object it's feeding) ?
Jonathan

jo**************@gmail.com wrote:
I have been experimenting with placing user controls (using Windows
Forms controls) into an ASP.NET webpage - and am completely stuck. I
can get a blank user control to work, but nothing beyond that. I have
tried making a very basic test rig to isolate the problem, and have
illustrated it below. For reference, this is using .NET 2 and Visual
Studio 2005.

Here's what I did - the first few steps explain what worked, then what
I did that broke it. If anybody can see the obvious thing I'm missing,
I'd love to hear from you.
1. Create a new "Control Library" solution - call it
"UserControlTestRig"
2. Modify the background color of the default control (UserControl1)
3. Compile, and test. The user control debug form pops up, and it works
fine.

4. Add a new ASP.NET website to the solution
5. Copy the compiled DLL of the user control to the root dir of the
website
6. Refresh the explorer in Visual Studio (to stop it complaining
further on)
7. Add the following to the default.aspx page...
<object id="uc1"
classid="UserControlTestRig.dll#UserControlTestRig .UserControl1">
</object>
8. Run the webpage - it appears, as does the user control with it's
background
color as set when we built it.

All is fine so far. Next I do the following, and have no idea why it
breaks...

9. Edit UserControl1 - add a label control to it (from the standard
windows form
controls)
10. Recompile UserControl1, and copy the DLL over to the web page.
11. Re-open the webpage, to see the usercontrol with the label...
*The control no longer works.*

What's more, once the control is broken, you can't then recompile
without the label, re-copy, and run the webpage again...

If somebody can explain why this is happening I'd love to know.

The maddening thing is I have a fairly complex series of controls that
this happened to this morning, and have spent all afternoon slowly
going backwards until I got to this example - at which point I held my
hands up and said "I'm going to ask on the internet"...
Jul 5 '06 #3
Thanks for researching this, i've been having the same problem.

Aug 3 '06 #4

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

Similar topics

0
by: Jim | last post by:
I am having some trouble with user controls and would appreciate any input / advice on where to go with this... :) 1. The first problem, and perhaps the root of the others, is that I have...
0
by: Jim | last post by:
I am having some trouble with user controls and would appreciate any input / advice on where to go with this... :) 1. The first problem, and perhaps the root of the others, is that I have...
5
by: Drew | last post by:
I have a user control written in C#. This user control uses some of my mixed mode C++ libraries. My user control is currently residing on a .NET Windows Form. Everything works nicely. Now I am...
7
by: Tim | last post by:
I am trying to load both server and user controls into placeholder controls on a aspx template page at runtime. These values would be strings that are returned from a database query. I know I can...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: Mark | last post by:
I am setting up an asp.net site using the Ektron CMS. Every page in the site uses the same basic template, with the look of the page changing via CSS and an id on the body. The id is shared by all...
1
by: Robert | last post by:
I have a large web site converted from 1.1 to 2.0 and in VS 2005, the IDE complains that in the ASPX file (html source): Error 1 Element 'stylesheet' is not a known element. This can...
2
by: o0JoeCool0o | last post by:
I am trying to create a User Control, that will be a message box with input options if I call okconf.visible = true in the page load of the user control it works fine, but if i then try to call...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.