Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Getting tag for block in controller -> action

Vote:
 

Hi!

If I have this controller and action ->

[TemplateDescriptor(AvailableWithoutTag = false, Inherited = true, Tags = new string[] { "Tag1", "Tag2" })]
    public class MyBlockController : BlockController<MyBlock>
    {
        [ChildActionOnly]
        public override ActionResult Index(MyBlock currentBlock)
        {
// How can I get what Tag this block has? return PartialView(currentBlock); } }

    

How can I, in code, get the tag this block is using in my action? I'm using the 7.5 - Display as feature so I want to know if it is full width, half width and so on. I've searched the web but been unable to find anything.
I know I can create a new controller and action and limiting the tags for each of theese and theryby knowing the tag but it seems overkill.

Thanks!

#85295
Apr 22, 2014 16:29
Vote:
 

Tested with AlloyTech:

public override ActionResult Index(ContactBlock currentBlock)
{
    var renderSettings = RouteData.Values["renderSettings"] as Dictionary<string, object>;
    if (renderSettings != null && renderSettings.ContainsKey("tag"))
    {
        var tag = renderSettings["tag"] as string;
    }
	...
}

    

Hope it helps

#85307
Apr 22, 2014 21:59
Vote:
 

Thanks Dejan! Your answerd saved me.

#88354
Jul 09, 2014 13:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.