User1397217187 posted
When trying to use a very simple custom web control (derived from WebControl):
"The file 'src' is not a valid here because it doesn't expose a type."
.aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="TestWeb.WebForm1" %>
<%@ Register TagPrefix="test" TagName="TestWebControl" Src="~/CustomWebControls/TestWebControl.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Here is the custom web control: <test:TestWebControl runat="server"/>
</div>
</form>
</body>
</html>
Custom control file /CustomWebControls/TestWebControl.cs
Custom control file ~/CustomWebControls/TestWebControl.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace CustomWebControls
{
public class TestWebControl : WebControl
{
protected override void Render(HtmlTextWriter output) {
output.WriteLine("<div>TestWebControl.Render</div>");
}
}
}