I am having issues with a simple custom control that I created by subclassing the hyperlink control.
I wanted to create a control called BackLink that would automatically grab the referring url to the page when it first loads the page. and on postbacks it would continue to use the initial value
I am able to capture and set the navigateurl property when the containing page first loads just fine but if the page submits to itself, the control loses its navigateurl value.
I have the enableviewstate property set in the aspx page but it doesn't seem to want to keep its viewstate
Am I missing something? Do I have to manage my own ViewState?
here is my code
public class BackLink : System.Web.UI.WebControls.HyperLink
this.Text = "<< back";
protected override void Render(HtmlTextWriter output)
if (this.Page.IsPostBack == false)
//save back url
Uri _backUri = this.Context.Request.UrlReferrer;
if(_backUri != null) this.NavigateUrl = _backUri.PathAndQuery;
else this.NavigateUrl = "/";
View Complete Post