Reset Design With Visual Studio on Asp.Net - asp.net

I am writing an ASP.NET webpage and accidentally I moved a control in the Design View and by trrying to put it back in position I completely destroyed the page layout.
I tried to delete the designer.cs file and Converting the page to a Web Application, cutting the code,saving pasting it and saving again, copying the code to a new Page. All with no result.
Is there an option like "Ignore the layout from the Design View" or similar?

The only solution I found was to delete the Project, download the last version from Team Foundation Service and work from there.

Related

site.Master file does not esist

Probably a silly question, being new to development, I am following tutorials and find references to a site.Master file in many of the tutorials I have come across. Is this something that is autogenerated or must I create this file myself? I have access to vs2010 and 2012 and I don't see a site.Master file in any of my projects that i have started. There is however a _layout.cshtml file. I only ask as in every tutorial that mentions this file, doe not mention creating it, just that the file exists.
Here is the deal.
You are probably reading tutorials about MVC or MVC 2 where the view engine is aspx and master pages still are used as a template.
Since MVC 3 a new engine is introduced: Razor. Also this _Layout.cshtml page takes the role of Site.master (master page). With Visual Studio 2010/2012 if you select an MVC project it defaults to Razor syntax and includes _Layout.cshtml as a Shared View.
You can still follow these 'old' tutorials, but mind this difference and act accordingly when recreating the steps.
It could be auto generated if the template you created your project from included a master file. Look in the Solution Explorer (If the solution Explorer isn't visible, hit View -> Solution Explorer) and see if you have a file in your site that ends in the extension ".Master". If not, right click your project in the Solution Explorer then click Add New Item. On the left select your language (Visual Basic or C#) then in the right select Master Page. Give it a name at the bottom such as site.Master. Then click Add. You'll have a master page.
After that, you'll probably want to hook up your other pages to use the new master page. But I'll leave that to your tutorials.
ASP.NET Master Pages: http://msdn.microsoft.com/en-us/library/wtxbf3hh.ASPX
site.master files are usually auto-generated for you when you make a new default ASP.NET website in Visual Studio. Depending on where are in your project, you may need to create one yourself, if Master Pages is the route you want to take. They aren't mandatory, they just make things easier IMO.
MVC has no concept of a masterpage, and site.Master doesn't exist. If you find a reference to site.Master on a tutorial you are using 'regular' ASP.NET (or, as I like to call it, if I'm trying to be polite 'old-fashioned' ASP.NET), not ASP.NET MVC
Yes , It is auto-generated when you create a new ASP Website Project in VS

Visual studio pulling a cached page

I think my visual studio is pulling a cached version of a webpage. See I am putting in code in the page, but when I run the website it never shows up.
And if I delete parts of the webpage, they still show when I run it.
I tried to rebuild but it still doesn't work.
When you say "putting code in the page," are you referring to the markup (aspx/ascx/cshtml/vbhtml/etc), or a code file (.cs, .vb)?
If you're modifying the code-behind file (webforms) or a controller (MVC), and you're (hopefully) using a web application project instead of a website project, you need to recompile the solution for your changes to take effect.

Any one know why changes made to a .aspx page in the designer are not saved by visual studio 2008?

im developing an asp.net website application but suddenly all changes i make to the page in the visual studio designer are not being saved for some reason. Every thing i do in the code behind file is saved with out any problem, also if i edit the .aspx file but in sourceview, the changes are saved, but if i drag a control from the toolbox onto the page designer and set some properties and then save, nothing will have been saved when i close and re-open the page, all changes are lost. Its confusing and i have no idea why.
Edit: also this happens on only one aspx file. All the other files edits are saved.
Edit: I have tried the hotfix here with no luck http://blogs.msdn.com/b/webdevtools/archive/2009/03/23/hotfix-for-design-view-does-not-update-html-and-to-designer-inserts-a-lot-of-nbsp.aspx
I think it is just a bug in visual studio. I have also experienced this behaviour, you edit things in design view then switch back to source view and the markup does not reflect the cahanges you made in design view. I have noticed it particulary when adding/editing columns in a gridview. Sometimes it works, sometimes not. I have never been able to work out a pattern.
If you have any of the auto-generated files open in the editor, this can stop the designer from persisting its changes.

newbie question about css property set up in Web developer 2010 Express

I am relatively new in C# and ASP.NET MVC.
There is something unusual that happens and it could be a simple property setup...
I have a MVC Web app and a css file associated with it in my Content folder.
Now everytime I do some changes in the css file I don't see these changes when I run the app. It seems that whatever I do the app keeps on using the old file. I can see it when I do a View Source on the page.
I played a bit with the Copy to Output Directory property in Web Developer without any good results.
Am I really missing something here ?
Thanks
Either restart casini, the web server for asp.net, the icon down by the clock or try hitting F5 in the browser a bunch of times.
Try clearing the cache in your browser.

How to consolidate ASP.NET master pages across applications?

First shot at throwing a question on these boards so hopefully I can get some help, here goes:
I am working to start up the .NET practice at my client. We have 5 small scale .NET applications in place currently with a few them of them live into production. They're mostly small reporting pieces with some data entry/business logic functionality. Each of these applications is currently using the identical master pages.
What I mean is that there is a copy of the same master page in each application. They are all basic website->WCF->BL->DB tiered applications. So I have 4 copies of the same master page that I have to change when I make a change to it.
The client DOES NOT want to consolidate all of these into a single solution. They like the separation of applications across sites. I just don't want to continue dealing with the hassle of multiple updates for common elements (which there will be many more of across these applications).
The code is all stored in team foundation server. We also do NOT want to compile the master page into a .dll and deploy it.
Can anyone please make some suggestions as to how I can maintain a single copy of these common files (master, .css, etc) across my multiple applications.
thanks in advance
You might want to look at Sharing Master Pages in Visual Studio.
If that is no help then you could try using Build Events in Visual Studio. I would pick one of the projects to be my "Main Project" and only edit the master page from that project. When you build the project it would run a command that would copy that master page(if it had changed) to your set locations.
The client DOES NOT want to
consolidate all of these into a single
solution. They like the separation of
applications across sites. I just dont
want to continue dealing with the
hassle of multiple updates for common
elements (which there will be many
more of across these applications).
The code is all stored in team
foundation server. We also do NOT want
to compile the master page into a dll
and deploy it.
You eliminated the only two real options there. What all is in the master page? Would it be possible to extract the HTML UI elements to a single template or series of template HTML files and import those dynamically into the master page? You could then relocate the common HTML to an arbitrary URL and have the master page for each application pull it in dynamically.
Edit: I lied. You could also use a VirtualPathProvider like Sharepoint does to store the master page in a database or some other directory, but beware that VirtualPathProviders do not work in MediumTrust environments.
See:
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
If you are using Web Applications (compiled into a dll) rather than Web Sites you can do the following:
Right click on the folder you want to store the master page in
Select "Add Existing Item..."
Browse to the master page on the file system, and select both the .master and the .master.cs files.
Then, rather than clicking on the "Add" button, click on the little down arrow to the right of Add, this will bring up a little menu with the options: "Add" and "Add As Link"
Select "Add As Link" this will reference the file in your project, while leaving it in the original location in your dev environment - this allows you to edit it in either application, while keeping it up to date in the other applications.
Obviously if you edit the code behind, you'll need to re-compile the other projects before you deploy the changes to those sites.
This isn't available in web site projects as they rely on the file structure to work out what is in the project.
EDIT: Missed the css part. Obviously you won't be able to serve those files, so this should only work for the master page.
Don't know your scenario, so
IF you can control the DNS / virtual directories to the applications you could use a format like this:
c:\inetpub\wwwroot\Application1
c:\inetpub\wwwroot\Application2
c:\inetpub\wwwroot\Application3
c:\inetpub\wwwroot\Application4
c:\inetpub\wwwroot\Application5
and have your Master page at c:\inetpub\wwwroot\master.Master,
c:\inetpub\wwwroot\master.Master.cs,
c:\inetpub\wwwroot\master.Master.cs.designer
Then you could reference the single copy of the master page from /../master.Master. I gave this a quick shot with a precompiled master page to make sure I could reach back beyond my root. You might have to give it a shot to see.
We use our source control to create links to the shared files in all the places that we need it. So if you edit in one place, you just need to do a get latest and it will appear in the other places you have linked it.
I ended up going with the VPP route. I created a virtual path provider and built my master page into a DLL and this is working. Now I have a massive problem though in that a Content page whos master page is late bound through the codebehind throws validation/formatting hissy fits because it thinks its should be a stand along page. my CNTRL + K, CNTRL + D has broken on every page where I'm now sharing my master page. This is extremely frustring for me and the team

Resources