I have a website project and want to put a hyperlink on the web page. To do this, I created a custom namespace in Default.aspx.cs. I got errors when building the solution. Is
the namespace code in the wrong place ? or do I need to create an assembly for it to fix the errors ? What am I missing ?
Here is the namespace, other details and errors:
In Default.aspx page I put
<%@ Register TagPrefix="study1wc" Namespace="study1.webcontrols" %> <study1wc:popupWindow NavigateUrl="http://www.google.com" runat="server" ID="test">testing</study1wc:popupWindow>
In Default.aspx.cs page I put
namespace study1.webcontrols { public class popupWindow : HyperLink {etc... }
protected override void Render(HtmlTextWriter writer)
{
HyperLink link = this;
writer.Write(
"<a");
if (!string.IsNullOrEmpty(link.NavigateUrl))
writer.WriteAttribute(
"href", "#");
if (!string.IsNullOrEmpty(link.CssClass))
writer.WriteAttribute(
"class", link.CssClass);
if (_intWindowHeight <= 0 || _intWindowWidth <= 0)
{writer.WriteAttribute(
"onclick", "window.open('" + link.NavigateUrl + "');return false;");}
else
{writer.WriteAttribute(
"onclick", "window.open('" + link.NavigateUrl + "','"+ _strPopupTitle +"','width="+ _intWindowWidth +",height="+ _intWindowWidth +"');return false;");}
foreach (string key in link.Attributes.Keys)
{writer.WriteAttribute(key, link.Attributes[key]);}
writer.Write(
">");
RenderContents(writer);
writer.Write(
"</a>");
}
protected override void RenderContents(HtmlTextWriter output)
{output.Write(Text);}
}
}
[Note: there is a RadGrid and RadComboBoxes defined after the custom namespace]Errors when I Build Solution:
Default.aspx - Warning Element 'popupWindow' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
Default.aspx - Error Unknown server tag 'study1:popupWindow'.