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: webapi=home&variant=dyn&tut=code-link-parameters-modify&name=2sxc
Current page URL with new parameter from string: https://2sxc.org/dnn-tutorials/en/razor/webapi/home/variant/dyn/tut/code-link-parameters-modify/name/2sxc
Current page URL with new parameter from .Add(...)
: https://2sxc.org/dnn-tutorials/en/razor/webapi/home/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>