Try our conversational search powered by Generative AI!

TemplateDescriptor Tags

Vote:
 

Is it possible to obtain current Tag that was used to resolve template renderer in context of template renderer (mvc controller)?

 

#79491
Dec 18, 2013 16:28
Vote:
 

I think you get get it from the RequestContext.RouteData.Values["tag"].  Try that,  I am not for sure but it should.

#79513
Dec 19, 2013 5:18
Vote:
 

That doesn't work atleast in my case when I used following statement in the view:

Parent View:

@{ Html.RenderContentData(content, false, "Card"); } //"Card" is tag that should be used to resolve render

 

[TeplateDescriptor(Tags=new []{"Card", "Line") ...]

MyController: ContentControler<MyContentType>{

public Action Result(MyContentType currentContent){

//... I want to switch actual view by current active tag

  
}
}

 

I've looked at decompiled code of RenderContentData method, and found out that it uses tag value passed only to resolve template. It doesn't put it anywhere.

So I assume that there is no out of the box way to do that.

 

 

 

#79519
Edited, Dec 19, 2013 10:33
Vote:
 

You can listen on:

public event EventHandler<TemplateResolverEventArgs> TemplateResolved;

    

then store in somewhere by self and reuse it after!

Hope that help!

Ha Bui

#79656
Dec 27, 2013 11:52
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.