I am new with ASP.NET. I am trying to migrate my .NET project(window form) to ASP.NET(web form). I have this custom control (derived from System.Windows.Forms.UserControl). I want to add this control to Web Form. Is that possible? Actually, I already registered the control and added the control to my new Web Form. However, when i ran it, i got this error message,
CS0011: Referenced class 'NRG.Cinesys.GUIControls.WWMarketsCombo' has base class or interface 'System.Windows.Forms.UserControl' defined in an assembly that is not referenced. You must add a reference to assembly 'System.Windows.Forms'.
Anybody can help? Thanks.
ChiaHi Chia,
The Windows Forms and Web Forms packages are quite different, so you're going to have a hard time using that control. The basic difference is that in WinForms, the control draws itself using Windows APIs while Web Forms controls spew HTML.
Do you have control of the source code for the WWMarketsCombo control? If so, youmight be able to adapt it to ASP.NET, but it'll take a ton of work.
If it's a third party control, you might want to see if they have an ASP.NET version.
Don
Hi Don,
Thanks for info.
I do have source code. However, I don't know how to adapt it to ASP.NET. It is the composite of picturebox, contextmenu and several menu items. I couldn't find contextmenu and menu items from Web Forms.
From the error message i got,
"You must add a reference to assembly 'System.Windows.Forms'"
I thought i could just add the reference to it. Is that correct? Even so, i don't know how to do it either. Could you help me with it? Thanks.
Chia
>I thought i could just add the reference to it. Is that correct?
Unfortunately not. As Don alluded to, the way objects are rendered in WinForms and WebForms is completely different. You *will* see controls in WinForms that have no WebForm equivelent. Your best bet is to look for WebForm control that someone has already built, or you could build your own, if you are so inclined. One place to look for existing controls is theASP.Net Control Gallery.
Regards,
Xander
Hi Xander,
It seems like there is no easy way out. Thank you. i think i just have to try to rewrite this control in WebForm then.
i have the other question. Since i am working on migrating WinForms project to WebForms, how much effort i should expect, in general? (i notice there's lots of controls or events we use do not exist in WebForms.) Thanks.
Chia
Hi Chia,
Lots of effort. It may seem like Win and Web forms apps work a lot alike, but that's mostly because Microsoft put in a lot of effort to make it seem like it. The infrastructure is completely different, however, including most of the events that you'll code against.
The worst problem is that if you try and do a port, as nearly as you can, you'll end up with a lousy Web forms application. I'd strongly suggest that you not take that approach. Instead, look at duplicating the functionality and perhaps the flows where it makes sense, and start from the ground up to rewrite the app.
You may be able to use some middle tier logic, but only if the Win forms app was designed with that capability in mind. That said, it'll be easier to adapt the logic and data stuff than the UI. Just throw out the UI and start over.
Sorry to bear bad news...
Don
0 comments:
Post a Comment