reusing a webform in visual studio 2010

how can i create webforms in visual mode and put them in a server control to be used on webapplications that reference the web control dll.

Thanks,
Luis
girosoftAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Jesse HouwingConnect With a Mentor Scrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
ascx and aspx fiels can't be shared across projects without investing in a serious amount of custom code (you'll need to write a custom FileSystemProvider for ASP.NET and configure that in your website).

What can be done is to create a server control. These are simple .NET classes that inherit from WebControl or Page. You can't use an aspx or ascx with these to store your mark-up, you'll instead have to build the control tree completely from code.

To make use of such server controls, you (in case of webcontrols) add them to the toolbox and drag them on your page. or in case of Page controls, you inhertit your aspx page from them. so replace public class MyPage : Page {} with public class MyPage : MyBasePage {}
0
 
MrunalCommented:
Can you please explain more what  you want to achieve with type of scenario?

Other option is:

Make user-control / custom-control.
0
 
girosoftAuthor Commented:
Hello,
I want to create a webform that performs certain tasks (like showing a grid with a list of products of a type), i can do that easialy if i create the webform as part of the webapplication, but what i want is to put that in a library (dll) that i can reuse in different webapplications, in visual studio 2010 there is no webcontrol library i guess now is server control, but i found no way of exposing the webform created in the library to the client webapplications.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kevp75Commented:
usually i do everything in the code-behind.  with VB we have XML literals that allow us to build things like a form, simply as

Dim _TmpForm = <form method="post" action="">
                          <%= 'Fields here %>
                          </form>

just do this in your class assembly...   make it a function with a datatype of string or XElement, build your form in it using XML literals, then return it
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
You can't easily share an aspx with different sites. What you can easily share are webcontrols and webparts, but they require a different way of working.
http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx

Alternatively, you can place your pages and usercontrols in a resource and load them through a virtual path provider:
http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx
0
 
Amandeep Singh BhullarCommented:
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
It's just not easily done.

To re-use parts of a page the recommended way is to create controls or usercontrols. And with a FileSystemProvider you can redirect a web application to a different storage location (as demonstrated in the second link I provided).

If it were as simple as the OP would like it to be, then this question would have been answered a long time ago.
0
 
Jesse HouwingScrum Trainer | Microsoft MVP | ALM Ranger | ConsultantCommented:
I hope that with this additional clarification, my answers can be AAccepted as answer to the question.
0
 
kevp75Commented:
I agree.   PAQ http:#37928058
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.