public override void AddAttribute(HtmlTextWriterAttribute key, string value) { if (value == null) { throw new ArgumentNullException("value"); } if (key.Equals(HtmlTextWriterAttribute.Href)) { if (!string.IsNullOrEmpty(this.href)) { base.AddAttribute(HtmlTextWriterAttribute.Href, this.href); if (value.StartsWith("javascript:") && !this.suppressJavascriptPostBack) { base.AddAttribute(HtmlTextWriterAttribute.Onclick, value.Substring("javascript:".Length) + "; return false;"); } } else if (!value.Equals("javascript:void(0)")) { if (value.StartsWith("javascript:")) { base.AddAttribute(HtmlTextWriterAttribute.Href, "#"); if (!this.suppressJavascriptPostBack) { base.AddAttribute(HtmlTextWriterAttribute.Onclick, value.Substring("javascript:".Length) + "; return false;"); } } else { base.AddAttribute(HtmlTextWriterAttribute.Href, value); } } else { base.AddAttribute(HtmlTextWriterAttribute.Href, "#"); } } else { base.AddAttribute(key, value); } }
public override void AddAttribute(HtmlTextWriterAttribute key, string value) { if(value == null) { throw new ArgumentNullException("value"); } if(key.Equals(HtmlTextWriterAttribute.Href)) { if(!string.IsNullOrEmpty(this.href)) { base.AddAttribute(HtmlTextWriterAttribute.Href, this.href); if(value.StartsWith("javascript:") && !this.suppressJavascriptPostBack) { base.AddAttribute(HtmlTextWriterAttribute.Onclick, value.Substring("javascript:".Length) + "; return false;"); } } else if(!value.Equals("javascript:void(0)")) { if(value.StartsWith("javascript:")) { base.AddAttribute(HtmlTextWriterAttribute.Href, "#"); if(!this.suppressJavascriptPostBack) { base.AddAttribute(HtmlTextWriterAttribute.Onclick, value.Substring("javascript:".Length) + "; return false;"); } } else { base.AddAttribute(HtmlTextWriterAttribute.Href, value); } } else { base.AddAttribute(HtmlTextWriterAttribute.Href, "#"); } } else { base.AddAttribute(key, value); } }