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: data310=page&tut=code-link-parameters-modify&name=2sxc
Current page URL with new parameter from string: https://2sxc.org/dnn-tutorials/en/razor/data310/page/tut/code-link-parameters-modify/name/2sxc
Current page URL with new parameter from .Add(...)
: https://2sxc.org/dnn-tutorials/en/razor/data310/page/tut/code-link-parameters-modify/name/2sxc
@inherits Custom.Hybrid.RazorTyped
@using ToSic.Razor.Blade
@{
// Example using string
var newParamsFromString = MyPage.Parameters + "&name=2sxc";
// Page parameters using .Add(...) method
var newParamsFromAdd = MyPage.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>