ASP.NET MVC ContentPlaceHolders out of order? - master-pages

I added a new ContentPlaceHolder (HeadContent) right below the Title so that I can add page-specific css and js files. But when I create a new View using the master page, it puts the default text of the page layout to have the HeadContent open/close tags at the end of the page. Unfortunately, I visually just see it as the first, second and third tags and start typing in my page's html into the last tag. But this isn't the BodyContent place holder because it is the second one. I have to go back and copy/paste them into the correct place. Ugh. Just for kicks, I scrambled all the tags around in the master page just to see what would happen in the view. Sure enough, VS.NET ignores their order in the master page and reorders them the same way everytime.
Why isn't VS just ordering the place holder tags in the same order as in my master page? Actually, how do I make it stop and just do it in the order I have in my master page?

What visual studio is doing (I assume) is loading the MVC View Content Template. I assume the reason all the contents are out of order from your master page is that Visual Studio Extensiblity loads the template then adds any ContentPlaceHolders that are not in the template after the template data.
You can see what the templates look like by going to your Visual Studio file in your Program files then goto Common7\IDE\ItemTemplates\CSharp\Web\MVC2.
There is also a folder for VB. In any case you can open the zip files located in that directory and drill down till you get to the .aspx page and you'll see what VS is inserting into your project when you do a Add New/View.

Related

sitecore webpage shows old content which is not present in .net mvc view.I don't want to show that content on web page

I am creating page in sitecore.It shows previously published content on page which is now not present anywhere in code.I want to remove that content.Also it does not show header and footer even I give correct placeholder name from layout file.
There might be few possible reasons for it, which you need to verify in your cms to fix this issue:-
1: You might added Sitecore level caching, verify below points in CMS.
i) Sitecore Rendering level cache.
ii) Sitecore page Presentation level cache.
iii) Code level caching
2: Do IIS reset with the below command in CM:-
CMD Window> iisreset

Is there a Visual Studio "Go to Partial" shortcut

I have an MVC project that uses a lot of Partial views, like in
#Html.Partial("_TasksGrid")
I happen to waste a lot of time looking for these partials and then finding that they are in the shared folder as opposed to the default folder and vice-versa.
My question is what would be the best way to navigate from one file to the other? Is there a shorcut/extension that can help me on this? I'd like to be able to put the cursor over the partial statement and press a shortcut that opens the partialview file.
In the end I got used to the "Edit.GoToAll" shortcut, but on my installation it had to be configured, I assigned Ctrl+T as my shortcut:
I can double click the partial name then hit Ctrl+T and the search will find the partial

When creating custom content editor (Editor tab) in sitecore, what the format of URL should be if I have desired aspx page in another VS project

When creating custom item editor in Sitecore(Editor tab), only required field is the Url, which will point to the .aspx page. Where this .aspx page should be added and what URL should I type. I've created a web application in Visual Studio and an aspx page with the desired functionality in it. This web application isn't related with my sitecore project. How to specify the URL to this page. Or should I add this page somewhere to sitecore project? Thanks in advance.
Go to core database, then in content editor go to /sitecore/content/Applications/Content Editor/Editors item. Create new folder item here if you like and inside create new item with this template: /sitecore/templates/Sitecore Client/Content editor/Editor (you can copy any existing editor item into your folder). You can set header, icon and Url (any url, absolute e.g. http://stackoverflow.com or relative e.g. /sitecore/shell/Applications/Media/Media Folder.aspx).
Now go to master database and set this editor in Editors field (inside template or specific content item)
I think you should move your Page.aspx inside sitecore project (in layout folder or custom one)
then url should be /layouts/Page.aspx

Generate Local Resource fails on asp.net mvc views?

Trying to localize a large existing MVC website, using Visual Studio 2010, MVC 4.
If I switch a view to the design view and then select Tools -> Generate Local Resource, none of the html text is pushed to a resource file and all I get is an app_localresources/pagename.aspx.resx file with one useless entry:
<data name="PageResource1.Title" xml:space="preserve">
<value><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></value>
</data>
Is there a setting that I'm missing that prevents this from working?
Or do we have to manually strip all the html text out of this large existing mvc website manually?
After doing some more googling, it appears that the VS tool for Generate Local Resource only runs on actual web form .net controls, and ignores all of the other aspx code and html text, so it's pretty useless for an MVC app.
We're going with a different route, which is to create a separate folder for copies of all of the view files, and have the app switch the view path at run time based on the user's selected culture.
We will just hand the whole separate folder of view pages to the translators and hope they don't screw up the aspx code too much. O_o And then the files will go back to the designers to fix the layouts. O_o
Otherwise, it'll take weeks to strip out all of the strings into resource files, and then the translators won't have the context of what they're translating, and the designers will have a fit because the layout will get screwed up.

Master Pages - Sharepoint 2007

I have created a Master Page in Sharepoint 2007. I am having difficulty with the main content. I have tried putting the content into the PlaceHolder Main but the content will not render on the page, the content consists of images (which I will eventually link to other pages). If I go outside the PlaceHolder and create a div and div id and connect the div id to my css it will render on the master page. That brings up a totally different issue, not only do the images render on the master page, but they also show up in all of my document libraries.
I have spent many hours trying to figure this out. I do not want to change any application pages. I have tried to apply the changes to the master page and not the rest of the site, I could not get that to work. I have tried moving the content to different Placeholders and the images still render in the libraries. Someone please help me to understand why the images from the master page show up in all of the document libraries. I would really really appreciate it.
Thank You.
Standard ASP.NET page generating at work here. The content in the master page content zone is replaced with the content in the page layout content zone. Without changing the application page you are stuck.
It sounds like you should be editing the application page anyway (because you don't want it to appear in all document libraries)

Resources