How to import aspx pages across different Visual Studio solutions? - c#

I'm very newer developing .NET web applications. Before read, I'm so sorry if I'm not able to explain correctly or if I'm confusing about something of .NET. Hope all of you can give me some light in .NET environment.
Context: We have two different solutions because the original idea was to develop two different applications with no common pages or content between them. Now, we need to have one of the aspx page that is in the solution1 inside the solution2 (and probably more in the future) because it's common between them.The idea is not to have two different maintenance of the same page. This two solutions have only one project inside them and each project has his own master page.
Solution1:
-Project1
Solution2:
-Project2
Question 1: Is it possible to import or use complete aspx page across the solutions? I mean, I know that is possible to import aspx files from the project1 into the project2, but doing this way, every change into the original aspx file of project1 means that is needed a new import into project2 (or this is what I think) to have the page up to date. What is the best way to share content between different solutions?
Thanks in advance.

You should be able to add the aspx page which exists in one solution (and version controlled hopefully!), to your other solution by adding it as a linked file.
MSDN explains how Visual Studio allows you to add an item as a link rather than directly adding the file to your project.
By linking to a file, you can capture ongoing changes to a source file without having to manually update a copy whenever changes are made. However, if the underlying file is deleted, the link will be broken.
To create a link to an existing item
In Solution Explorer, select the target project.
On the Project menu, select Add Existing Item.
In the Add Existing Item dialog box, locate and select the project
item you want to link.
From the Open button drop-down list, select Add As Link.
https://msdn.microsoft.com/en-us/library/9f4t9t92(v=vs.90).aspx#Anchor_0
Another helpful article by Grant Winney on the topic here:
https://grantwinney.com/visual-studio-add-file-as-link/

Related

VSIX extension that creates a .cs file in the current project when a button is pressed

In short, im creating a Visual Studio extension in c# that enables non-automation testers to create automation scripts for web based solutions (using selenium).
We've created a template already for users that lays out the project file structure (test runners etc) and im using windows forms toolbox controls to create the dialogue windows where they will enter things like URls, Xpaths, page names etc etc
My question is this;
How on earth do i go about creating .CS files dynamically based on their inputs in these toolbox windows?
The simplest (he says) window i have is one that simply allows them to enter a URl and a webpage name. When they click the 'ok' button on this window, it should create a new .CS file with the webpage name as the class name, the url as a string that the webdriver can use to kick off the test and a few other bits and pieces as a template for them to start adding web elements to.
Any guidance would be greatly appreciated, there seems to be precious little around the web about creating VS extensions!
You got a few options here.
Typically, most people would do this by implementing a custom project item template, along with a custom IWizard based wizard associated with your template.
If you are displaying a modal UI from your IWizard.RunStarted, you can simply populate the ReplacementsDictionary with the text gleaned from your custom UI, which would then be swapped for the tokens in your templatized .cs file.
Or you could programmatically add code to the file after it was generated and added to the project (admittedly a much uglier and more difficult to code).
And finally, you could just generate the file in the project directory, and programmatically add it after the fact.
There's a number of old blog articles from the archived VSX Arcana blog that you might also find helpful.

How to import existing form, from another to c#?

We are importing form, from existing project to our new project.
It works well in run time, but we can't see controls to modify them in design mode!
Do you know how what we do to see them?
i found it, when i add exist form to my project, in addition add formX.cs, also add another along files (designer and res). thats enough add formX.cs .

Share PartialView between projects in a solution?

I am developing 2 MVC5 websites. They run seperately, but actually related to each other (1 Admin site, and 1 User site). In both site, I have to render a graphical board using HTML table. I am using PartialView with a Model to render it.
Currently, this is my solution structure:
Project.Common (A class library project, contain the model)
Project.Admin (MVC5 project for the Admin site), refering to Project.Common.
Project.User (MVC5 project for User site), refering to Project.Common.
To render the graphical board, I will use BoardData class from Project.Common, which is ok. But with current solution structure, I have to create 2 PartialView in each MVC5 project, which may be hard to maintain later.
Please suggest a good solution for reusing the PartialView. I already know I can write Helper, but that way, I have to write HTML code inside C# code, which is not very good. Is there any way to do this within Razor View?
One of the options you can use is add a link to a file. In this case keep your Partial view in just single project and in second project use Add -> Existing Item, select your partial view from the first project and click on a small down arrow next to the Add button and choose Add as Link. More info can be found on MSDN, see section Add an existing item as a link.
In this case you will have a partial view only in one project and any changes to it will automatically be applied to other project as well.
You should embed your views into the Project.Common dll, a detailed description can be found on https://visualstudiogallery.msdn.microsoft.com/f28290ce-d987-4f91-b034-707031e10ce6

Create a dynamic project template in VS 2010?

This might sound a bit of an odd question but I know what I want to achieve, just don't know if it's possible.
Firstly, I'd like to be able to create a visual studio project that the 2 developers that work with me can use as a basis for all new websites. I want to drop all the common files that we use in there, like jQuery, CMS files etc. so that every time they start a new project they don't have to worry about all of that stuff. I guess to do this I just set up a project and "File > Export Template" ?
Now, here's the tricky bit...
When you open up one of the default templates in VS it asks you a few questions, such as if you want to use a master page or if you want to use code behind etc.
What I would like to do is set up something similar so that when you use the project template it asks you what version of jQuery you want to use so that it can import the right file, or for example it might ask you if you want to include certain user controls that the CMS contains. If you tick the box then the folder with the necessary user controls would be put in your new project for you.
I know MS can do this but can a user like me include functionality like that in my own project template?
Hope that makes sense.
Some more digging turned up the iWizard interface and this tutorial...
http://msdn.microsoft.com/en-us/library/ms185301

C# asp.net Howto load an aspx page from another project?

I have 2 projects. One project is a core and contains the GUI which is always the same and acts like a kind of framework.
The second project is an application that must be set in the framework.
The framework consists of a masterpage and a content page (application.aspx). From my second project I want to load the application.aspx. Is this possible? And if so.. how?
We did very similar thing in our projects
We add the folder/files in our source safe, and share these folders/files to other projects from source safe
Server.Transfer("application.aspx");
will take you there. What do you mean by
load the application.aspx?

Categories

Resources