1. make sure your 服务器控件 has a namespace
2. compile the 服务器控件 cs file into a dll and copy it to the bin directory of your virtual directory
3. try something like the following in your aspx page:<%@ Register TagPrefix="my" Namespace="YourControlNamespace" Assembly="YourControlDLLNameWithoutTheExtension" %><my:YourControlClassName id="whatever" runat="server" />
2. compile the 服务器控件 cs file into a dll and copy it to the bin directory of your virtual directory
3. try something like the following in your aspx page:<%@ Register TagPrefix="my" Namespace="YourControlNamespace" Assembly="YourControlDLLNameWithoutTheExtension" %><my:YourControlClassName id="whatever" runat="server" />
解决方案 »
- GridView点编辑怎么没有反应?怎样实现增加一行的效果?
- 浏览器兼容问题……求高手给点意见和方法。
- 谁能帮下忙,下边的数据层,哪里应该关闭?
- 想在textbox_textchanged()中加个gridView绑定数据库的事件,应该怎么做?
- 同一个页面多个相同控件的处理问题.......
- 请问ASCX用户控件现在还推荐使用吗?还是大家都改用母版页?
- 为什么得不到数据绑定的传递的参数?请高手指教!
- DATAGRID分页
- 在线等待:DataGrid中如何只指定某一个单元格有超级链接!
- 请问DataGrid如何实现如下分页?
- 在DATAGRID中加入CHECKBOX的問題??
- DataGrid更新语句到数据库出错,提示: System.Data.OracleClient.OracleException: ORA-01745: 无效的主机/赋值变量名
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace wdfx_test
{
public class WebCustomControl1 : WebControl
{
private string text;
public string Text
{
get
{
return text;
} set
{
text = value;
}
}
protected override void Render(HtmlTextWriter output)
{
output.Write("这是第一个自一义控件");
}
}
}
引用控件的文件:CustomControl.aspx为:<%@ Register TagPrefix="CC1" Namespace="wdfx_test" Assembly="customcontrols"%>
<%@ Page language="c#" Codebehind="CustomControl.aspx.cs" AutoEventWireup="false" Inherits="wdfx_test.CustomControl" %>
<HTML>
<HEAD>
<title>CustomControl</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="CustomControl" method="post" runat="server">
<CC1:WebCustomControl1 runat="server" id="wc1" />
</form>
</body>
</HTML>
而且在BIN下也生成了customcontrols.dll
但运行时出现以下错误:
基类包括字段“wc1”,但其类型 (wdfx_test.WebCustomControl1) 与控件 (wdfx_test.WebCustomControl1) 的类型不兼容。源错误:
行 12: <body MS_POSITIONING="GridLayout">
行 13: <form id="CustomControl" method="post" runat="server">
行 14: <CC1:WebCustomControl1 runat="server" id="wc1" />
行 15: </form>
行 16: </body>
<HTML>
<body MS_POSITIONING="GridLayout">
<form id="CustomControl" method="post" runat="server">
<CC1:WebCustomControl1 runat="server" id="wc1" />
</form>
</body>
</HTML>