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