Tuesday, September 28, 2010
Binding a Custom Meta field to a Template in Sitefinity with a ASP.NET Usercontrol
To get the background about this issue please read this article in Sitefinity knowledge base.
The last section of the article suggests that you can use the following syntax to set the NavigateUrl property of the ASP.NET Hyperlink control with its Text property
However the above doesn’t work and <%= %> is rendered as plain text
After trying to figure this out for a while I found the following way to do this, the trick is to create a custom user control that implements ITextControl interface, like this
The highlighted line above sets the NavigateUrl property from the Text value that is bound to the control.
The ASCX part of the user control simply has a ASP.NET Hyperlink control in it
To use this control just add a reference in the Template usercontrol that Sitefinity uses and your on your way.
Hope this little trick helped you, let me know.
Also if you follow my blog I suggest you check out my new home on the web zubairahmed.net (Know that I have to put a message here). See you there.