Because MyPage.Parameters
/ CmsContext.Page.Parameters
follows the query string convention adding a new parameter isn't too difficult.
To add a new parameter you can use the .Add(key, value)
method or add the parameters as string following the convention as for example &name=2sxc
.
⬇️ Result | Source ➡️
See adjusted page parameters: turn-on100=page&mode=pngfav&variant=dyn&tut=code-link-parameters-modify&name=2sxc
Current page URL with new parameter from string: https://2sxc.org/dnn-tutorials/en/razor/turn-on100/page/mode/pngfav/variant/dyn/tut/code-link-parameters-modify/name/2sxc
Current page URL with new parameter from .Add(...)
: https://2sxc.org/dnn-tutorials/en/razor/turn-on100/page/mode/pngfav/variant/dyn/tut/code-link-parameters-modify/name/2sxc
@inherits Custom.Hybrid.Razor14
@using ToSic.Razor.Blade
@{
// Example using string
var newParamsFromString = CmsContext.Page.Parameters + "&name=2sxc";
// Page parameters using .Add(...) method
var newParamsFromAdd = CmsContext.Page.Parameters.Add("name", "2sxc");
}
<!-- unimportant stuff, hidden -->
<p>Current page URL with new parameter from string: @Link.To(parameters: newParamsFromString)</p>
<p>Current page URL with new parameter from <code>.Add(...)</code>: @Link.To(parameters: newParamsFromAdd)</p>