#4 CmsContext.Page – Id, Parameters, etc.
Requirements
Resources
Interface ICmsPage
Get information about the page which is the contxt for the currently running code.
On the new RazorPro
it's on MyPage
or on MyContext.Page
.
On the older Razor14
or Razor12
it's on CmsContext.Page
.
Output
-
.Id
of the current page: 37 (TabId
in DNN orPage.PageId
in oqtane.) -
.Url
the page url with protocol: https://blazor-cms.org/oqtane-tutorials -
.Parameters
all the url parameters of the pagec140=page
-
.Parameters[name]
Access a specific parameter (in this case the parameterc140
from the url) page
#4 CmsContext.Page – Id, Parameters, etc.
Source Code of this file
Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code
@inherits Custom.Hybrid.RazorTyped @using ToSic.Razor.Blade; <!-- unimportant stuff, hidden --> <div @Sys.PageParts.InfoWrapper()> @Html.Partial("../shared/DefaultInfoSection.cshtml") <div @Sys.PageParts.InfoIntro()> <h2>Interface ICmsPage</h2> <p> Get information about the page which is the contxt for the currently running code. </p> <p>On the new <code>RazorPro</code> it's on <code>MyPage</code> or on <code>MyContext.Page</code>.</p> <p>On the older <code>Razor14</code> or <code>Razor12</code> it's on <code>CmsContext.Page</code>.</p> </div> </div> <ol> <li> <code>.Id</code> of the current page: <strong>@MyPage.Id</strong> (<code>TabId</code> in DNN or <code>Page.PageId</code> in oqtane.) </li> <li> <code>.Url</code> the page url with protocol: <strong>@MyPage.Url</strong> </li> <li> <code>.Parameters</code> all the url parameters of the page <code>@MyPage.Parameters</code> </li> <li> <code>.Parameters[name]</code> Access a specific parameter (in this case the parameter <code>c140</code> from the url) <strong> @MyPage.Parameters["c140"] </strong> </li> </ol> @* Snippet for the old v14 code, which shouldn't run but should be shown. This is a bit of a hack, but it works <ol> <li> <code>.Id</code> of the current page: <strong>@CmsContext.Page.Id</strong> (<code>TabId</code> in DNN or <code>Page.PageId</code> in oqtane.) </li> <li> <code>.Url</code> the page url with protocol: <strong>@CmsContext.Page.Url</strong> </li> <li> <code>.Parameters</code> all the url parameters of the page <code>@CmsContext.Page.Parameters</code> </li> <li> <code>.Parameters[name]</code> Access a specific parameter (in this case the parameter <code>c140</code> from the url) <strong> @CmsContext.Page.Parameters["c140"] </strong> </li> </ol> *@ @* Footer *@ @Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })