I have created a web user control called ColorChooser.ascx in VB.NET. I would like to use this same control in a C# Web application. How do I go about compiling or adding the control to the C# project?
Take the two or 3 files, .ascx, .cs and possibly a .resx, copy to the directory, go to project-->show all files, right-click on the file --> include in project. Just make sure when referencing that you use the right namespace.
you can't add it to a c# project before changing all the serverside code to c#. The ColorChooser.ascx.vb file should be changed to ColorChooser.ascx.cs and all the code in it should be changed to c# code. In your ColorChooser.ascx file, change the Codebehind and Language attributes of the @Page directive to reflect the c# changes
No, because you need to copy the ascx file of the user control to the project, so you have to change the @Page directive to reflect the c# changes as I said earlier. User controls are different from custom controls.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.