Skip to main content
deleted 9 characters in body
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[ The datasource item's path is set in the rendering itself and not in the presentation details. ]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings areThe View rendering is loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, triedTried with and without assigning a Sitecore model to the rendering.

Using Sitecore 8.2

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[ The datasource item's path is set in the rendering itself and not in the presentation details. ]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[ The datasource item's path is set in the rendering itself and not in the presentation details. ]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

The View rendering is loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

Tried with and without assigning a Sitecore model to the rendering.

Using Sitecore 8.2

added 9 characters in body
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[The[ The datasource item's path is set in the rendering itself and not in the presentation details.] ]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[The datasource path is set in the rendering itself and not in the presentation details.]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[ The datasource item's path is set in the rendering itself and not in the presentation details. ]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

added 208 characters in body
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

There is a controllerController rendering and in its Data source field, I gave the path of the datasource item.

[The datasource path is set in the rendering itself and not in the presentation details.]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a viewView rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

There is a controller rendering and in its Data source field, I gave the path of the datasource item.

[The datasource path is set in the rendering itself and not in the presentation details.]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a view rendering. The code returns empty value.

Using Sitecore 8.2

There is a Controller rendering and in its Data source field, I gave the path of the datasource item.

[The datasource path is set in the rendering itself and not in the presentation details.]

I can get the datasource item in code like this

string datasourceId = Sitecore.Mvc.Presentation.RenderingContext.CurrentOrNull.Rendering.DataSource;

But the same is not working for a View rendering. The code returns empty value.

Both the renderings are loaded from the layout's cshtml like this

@Html.Sitecore().Rendering("<path of the rendering>")

For the View rendering, tried with and without assigning a Sitecore model.

Using Sitecore 8.2

Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78
Loading