1

i have written an asp.net user control in vb.net. now i have a c# web application that i need to use this control in, is there some way to export this user control into a dll or something to be able to resuse it

1
  • do you have asp.net web application project for user controls? Commented Sep 16, 2013 at 3:14

2 Answers 2

1

You better move your shared controls to vb.net web application project, then you can reuse that in both vb.net projects and c# projects

Steps:

  1. create vb.net project with shared user controls. You can create Folder called Controls and put all the user controls there.
  2. add above shared project to your c# project and create pre buld event to copy ascx files to c# project like below copy "$(SolutionDir)SharedControl\*.ascx" "$(ProjectDir)Controls\"
  3. you need to add reference to shared control project
  4. register the controls and use it

ASPX

<%@ Register Src="~/Controls/WebUserControl1.ascx" TagPrefix="uc1" TagName="WebUserControl1" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
         <uc1:WebUserControl1 runat="server" ID="WebUserControl1" />
Sign up to request clarification or add additional context in comments.

3 Comments

+1 @Damith - We have used this approach and liked it. Easier to look at the control's code and to modify to meet new requirements.
i have tried that before i made this post, but unfortunately it is not working. i have a solution, with 2 asp.net web applications, one in c# and the other one in vb.net, i created a user control in the vb.net project, then draged and dropped it on a webpage in the c# project. and i got this error postimg.org/image/renrxhv9f , please tell me what i am doing wrong? thank you
you need to copy ascx files to your project
0

Publish your vb.net project to some folder. That will generate dll. Drop that dll to your c# project's bin. Drop ascx control to some folder in your c# project. Register tag prefix and you are done.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.