All-Star
53631 Points
23988 Posts
Jun 22, 2020 11:02 AM|mgebhard|LINK
Web Forms uses server controls. Replace the link with a standard HyperLink server control which provides access to the NaviagtionURL property.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.hyperlink?view=netframework-4.8
If you must use an HTML element then use a code block.
<a href='<%=YourPageProperty%>' id="Test">Test1</a>
public partial class _Default : Page { public string YourPageProperty { get; set; } protected void Page_Load(object sender, EventArgs e) { YourPageProperty = "/About.aspx"; } }
All-Star
53631 Points
23988 Posts
Re: assigning the href tag in code behind with href in aspx page and link inside the cs code
Jun 22, 2020 11:02 AM|mgebhard|LINK
Web Forms uses server controls. Replace the link with a standard HyperLink server control which provides access to the NaviagtionURL property.
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.hyperlink?view=netframework-4.8
If you must use an HTML element then use a code block.