Questions tagged [razor]

Questions relating to the Razor syntax used in ASP.NET MVC and ASP.NET Web Pages.

Filter by
Sorted by
Tagged with
15
votes
1answer
5k views

Editable Sitecore fields with Glass

Folks I'm trying to do something basic here which is have a general link and an image field as editable in experience editor on my view using Glass. my end goal is to have two editable fields which ...
12
votes
3answers
13k views

C# MVC razor view - HtmlHelper does not contain a definition for 'Sitecore'

Has anyone experienced an error described in the image below where the HtmlHelper in razor view is not recognizing Sitecore when I try to specify a placeholder? Thanks for your help!
6
votes
1answer
702 views

Is there a way to supress rendering width and height attribs using Fortis Image.Render?

Using Fortis Image.Render, is there a parameter to suppress rendering the Width and Height attributes? Example of the image: @Model.ImageField.Render(new { @class = "my-class-name" })
5
votes
3answers
423 views

How to Render @Html.Sitecore().Field using custom Model Item in Sitecore MVC

I have a model ArticleItem which has some fields that I populate with some Business Logic. Now on the view where I return ArticleItem I want to render a RTE content so that it is Page Editor friendly ...
5
votes
1answer
548 views

Custom View Engine for Razor View Helix-type default paths

Has anyone been able to make a habitat-compatible razor view engine? Basically I'd like something that can dynamically search "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" "~/Views/{<...
3
votes
1answer
2k views

Glass BeginRenderLink not showing text node

<a href="https://google.com" class="link" ></a> <a href="https://google.com" class="link" >Text Node</a> @using (Html.Glass().BeginRenderLink(m => m.Link, new { @class =...
3
votes
1answer
943 views

Sitecore instance is very slow after deployment in Azure Paas

Sitecore version - 9.0.1 (rev. 171219) After every deployment, to load the home page it is taking at least 20 mins thereafter every new page takes 2 mins on the first instance there after its pretty ...
3
votes
1answer
95 views

Sitecore Helper to render SXA Component inside cshtml

I need to render the Social Media Share component in the cshtml of Cloned Search Results, is there a Sitecore Helper to render a component in the view? I am using SXA 1.8 so I know that we have the ...
3
votes
1answer
349 views

Item preview fails with “Section or group name 'system.web.webPages.razor' is already defined”

I've created a Coveo search page using the reference here: https://developers.coveo.com/display/public/SitecoreV4/Inserting+and+Customizing+a+Search+Interface+Component. When I try to preview it, I ...
2
votes
2answers
54 views

Put Sitecore component on page based on QueryString

We have a Sitecore component that displays a list of blog posts. Part of this component is a placeholder where a "Featured Blog Post" component may be placed by editors manually. The "Featured Blog ...
1
vote
1answer
30 views

Search Results caching

I cloned Search Results Component and when I edit any thing in cshtml inside else scope <div @Html.Sxa().Component(Model.Rendering.RenderingCssClass ?? "search-results testShaimaa", Model....
0
votes
1answer
14 views

How to cache bust CSS and JS assets in Sitecore Helix

I want to be able to loop through my views, particularly my main layout and apply a query string cache buster to our CSS and JS calls as follows: <link rel="stylesheet" href="/assets/css/style.css?...
0
votes
0answers
23 views

Edit frame in a page with synonyms fields [duplicate]

I'm new to experience editor in sitecore. I'm writing an edit frame in razor page using as datasource the page item ID. The edit frame should modify some fields read by a rendering in the page. But ...
0
votes
1answer
47 views

Razor-Inserted Value rendering as Type String instead of Expected Value

We're encountering a strange issue from one environment to the other that we can't seem to get to the bottom of. We're using Azure for hosting as well. On all environments, we have the following code:...
0
votes
1answer
363 views

Glass RenderLink not rendering right media url

Sitecore verison - 9.0.2 Glass version - 5.0.6.0 We are trying to use Glass @RenderLink to render a pdf media item, it's generating anchor tag with below path /sitecore/media-library/site-content/...