开发者

add c# user control to existing asp.net vb.net project

I've g开发者_开发问答ot an existing asp.net project written in vb.net. Another person has written a user control in c#.

Could you please let me know the steps for adding that C# user control to the vb.net app?

I've tried copying them to the folder and using "Add existing item", however it doesn't compile the code behind at all.

Thanks, Fidel


create a new asp.net user control library project with c#, add C# user control to that project, than in your visual basic project add reference to that library and that's it ;)


You could use this tool to add the control to the VS toolbox.

An example of usage (choose either /vs2005 or /vs2008 depending on your VS version):

TOOLBOX.EXE [/vs2005] [/vs2008] /installdesktop assembly tabname


The C# control will need to be in a seperate dll. You can then add a reference to this dll in your vb project. Then register the control in the page directive or web.config, like normal.


Just wanted to add another way to accomplish this, as I was just about to ask a question regarding this topic and figured out the solution.

If you truly need to bring over the raw user control files into a new project, you will find simply adding them via 'Add -> Existing Item...' will make each file come into the solution independently and not structure them properly in Solution Explorer.

The trick is to open up the (2) associated user control code files outside of VS.NET prior to adding to your solution and modify thier namespace to be that of your new project. So if in the old project your namespace was:

MyOldProject.CustomControls

...you will want to rename in the .cs and .Designer.cs to the following:

MyNewProject.CustomControls

Then when you go back into VS.NET add add all of the existing items, they will be in their proper arrangement as follows:

MyControl.cs
-->MyControl.Designer.cs
-->MyControl.resx
-->MyControl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜