User control from Form to ASP.NET application

  • Thread starter Thread starter Drew
  • Start date Start date
D

Drew

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 trying to use this control on a ASP
web page. I use the wizard (VS 2003) to create an ASP application and
drop my control onto the ASP page, I get :

"Operation cannot be completed"

I have checked and all of my C++ libraries are in the bin directory of
my ASP application. This shouldnt be a dependency issue. Anyone know
what is causing this? I have no idea even how to debug the situation.
The error is very vague.

Thanks...

Drew
 
Hi Drew,


Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, I understand that you've made a custom control which
references some Mixed c++ dlls. The control can be used in Winform
correctly. Then, you'd like to use it in a ASP.NET web page. However, when
you try to add it onto a web page, you encountered the
"Operation cannot be complete" error.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

If my understanding is correct, I'd like to query some further info on this
issue:
1.The UserControl you created is a winform control derived from
System.Windows.Forms.Control , isn't it? If not, would you please describe
it more detailed?

2. If it's a winform control, do you mean to directly use a winform control
in webpage(in IE browser) or just want to add a Such custom control in a
web page?

In dotnet, there are two different kinds of controls:
1. the winform controls which are derived from the
System.Windows.Forms.Control
These controls are used in winform application.

2. the web controls which are derived from the System.Web.UI.Control
These controls are used in ASP.NET web pages.
Also, you can create your own custom web controls which derived from the
System.Web.UI.Control

However, since the two kinds of controls are quite diferent from each
other(in their internal implement mechanism). They are not able to used in
other's enviroment (such as using web control in winform or using winform
control in web page are not generally recommended).
If you want to create some custom controls which can be used in ASP.NET web
page. You can have a view on the following tech articles in MSDN:

#Developing ASP.NET Server Controls
http://msdn.microsoft.com/library/en-us/cpguide/html/cpcondevelopingwebforms
controls.asp?frame=true

Please check out the preceding suggestions to see whether they are helpful.
If you have any quesitons or if you feel my suggestion not quite
appropriate for your situation, please feel free to post here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Steven,

No it is not a winform. It is a user control. I am able to drop that
user control onto a winform and it works perfectly. Now when I drop
this same user control onto an ASP page, I get the error previously
stated.
 
In other words I cannot use a winform control in an ASP page. Ill read
the article you mentioned for more information. Thank you.
 
Hi Drew,

Thanks for your response. As I mentioned in last reply. Generally, we
should use different type of control in different kinds of applications.
In winform application, we use windows control(we can create such control
by windows control library project). In ASP.NET web application, we use web
controls(which can be created by web control library). They're quite
different. Please check out the tech articles I provided last time.

Also, here is some further tech articles in ASP.NET QuickStart on Web
usercontrol and server control:
#Web Forms User Controls
http://samples.gotdotnet.com/quickstart/aspplus/doc/webpagelets.aspx
#ASP.NET web custom control
http://samples.gotdotnet.com/quickstart/aspplus/doc/webctrlauthoring.aspx

If you have any questions, please feel free to post here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top