Developer forum

Forum » Templates » Global:Area.ID with razor?.

Global:Area.ID with razor?.

Mikkel Toustrup Olsen
Reply

Hello,

I came across a rather odd issue. Isn't it possible to retrieve the Global:Area.ID with razor within a paragraphtemplate?.

My code returns "" - which means the ID doesn't exist? ..

@{

    var areaId = GetValue("Global:Area.ID"); (have tried GetValue, GetString, Integer and etc. without any luck..)
    switch(areaId)
    {
        case "1": pathForDepartmentList = "Default.aspx?ID=119";
        break;
        case "2": pathForDepartmentList = "Default.aspx?ID=119";
        break;
        case "4": pathForDepartmentList    = "Default.aspx?ID=119";
        break;
        default: pathForDepartmentList    = "rammer ikke!!";    
        break;
        
    }
}

 

<form method="post" action="@pathForDepartmentList">

some code here...

</form>

 

Regards,

MikkelTO


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Mikkel

Use GetGlobalValue("Global:Area.ID");

or the API:

Dynamicweb.Frontend.PageView.Current().Area.ID;

Votes for this answer: 1
 
Mikkel Toustrup Olsen
Reply

Thanks, i got it working by the API - i totally missed that in the documentation. Sorry for the double post - I was a bit eager with my Submit ^^

Regards,

MikkelTO 

 

You must be logged in to post in the forum