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

  • Thread starter jonathan.beckett
  • Start date
J

jonathan.beckett

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"...
 
J

jonathan.beckett

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
 
J

jonathan.beckett

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

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