I have a 2sxc Content module that uses C# Razor for the template. In my content type, I have a field called "Link" and the type is a Link that's configured to only allow the user to select a DNN page from the dropdown.
When the user chooses a page from the dropdown, it puts something like "page:38" where "38" is the DNN tab ID.
In my C# razor template, I put @Content.Link and it will output something like domain.com/our-services. (our-services being the URL associated with the tab ID 38).
I'm building something where I want to actually output just the page ID. So instead of @Content.Link outputting /our-services, I want it to output the page ID "38".
How can I do this in c# razor?
Absolutely. Let's say your field is called Link
then as of now you're doing @Content.Link
. This will auto-resolve links.
If you don't want to auto-resolve, you must use Content.Get("Link", convertLinks: false)
to get the original string, and then extract the ID with substring or regex.