我下载了一个朋友开发的服务器控件,他的使用实例是用的html写的,我如果有C#代码写请问怎么使用呀,在“工具箱”中的“WEB窗体”中的控件中也没有,我怎么声明和使用呢?
源程序的使用实例是:
<cbc:NormalButton id="NormalButton1" onclick="normalBtn_Click" runat="server" Message="您确定要点击该按钮吗?" Text="普通确认按钮" Height="54px"></cbc:NormalButton>
HTML的程序头部是这样的:
<%@ Register TagPrefix="cbc" NameSpace="ConfirmButtonControl" Assembly="ConfirmButtonControl"%>
<%@ Page language="c#" %>
服务器控件源程序头部是这样的:
namespace ConfirmButtonControl请问一下各位朋友,在C#代码下,我怎么样调用已经定义好的服务器控件呢?
谢谢大家了!!!!
谢谢!!
源程序的使用实例是:
<cbc:NormalButton id="NormalButton1" onclick="normalBtn_Click" runat="server" Message="您确定要点击该按钮吗?" Text="普通确认按钮" Height="54px"></cbc:NormalButton>
HTML的程序头部是这样的:
<%@ Register TagPrefix="cbc" NameSpace="ConfirmButtonControl" Assembly="ConfirmButtonControl"%>
<%@ Page language="c#" %>
服务器控件源程序头部是这样的:
namespace ConfirmButtonControl请问一下各位朋友,在C#代码下,我怎么样调用已经定义好的服务器控件呢?
谢谢大家了!!!!
谢谢!!
解决方案 »
- 帮忙把这个DLL中公开函数改成C#类型的
- 求和排序函数
- 急!很急!jQuery 出现了运行时间错误。'$'未定义 求大虾解答
- C# 图层问题
- 序列化类到数据库和反序列化
- 动态调用webservice遇到的问题
- 如何让用户自己添加和设计控件?急!!
- 如果内存中DataSet中指定的Tatble字段值?谢谢!
- 程序发布后样式在谷歌浏览器中浏览正常,在IE中错乱
- 高分请教一个问题,在线等,解决问题立即结帖了,真急... ...
- datagrid(windows控件),想通过行号取得一条记录的某一单元格的值,怎么取,因为没有ITEM类似的属性,很急!
- ············关于在remoting中传输SqlParameter的问题,请高手回答。是不是没有解决方法?100分
服务控件源程序如下:我该怎么做呢?谢谢了!!!
using System.ComponentModel;
using System.Drawing;
using System.Collections.Specialized;namespace ConfirmButtonControl
{
/// <summary>
/// NormalButton 显示为一个普通样式按钮。
/// 当用户点击按钮之后,跳出一个确认对话框来确定其动作。
/// 通常多用于确认用户是否确实要进行删除/修改等类似的操作。
/// </summary>
[ToolboxData("<{0}:NormalButton runat=server></{0}:NormalButton>")]
public class NormalButton : Button
{
private string _scriptPath = "ControlClientScript/";
//构造函数
public NormalButton():base()
{
Message = "您确实要这样做吗?";
}
#region 定义属性 [Bindable(true),
Category("Appearance"),
DefaultValue("您确实要这样做吗?"),
Description("自定义提示信息")]
public string Message
{
get
{
return (string)ViewState["Message"];
} set
{
ViewState["Message"] = value;
}
}
[Category("Other"),
DefaultValue("ControlClientScript/"),
Description("脚本路径")]
public String ScriptPath
{
get
{
return _scriptPath;
}
set
{
_scriptPath = value;
}
} #endregion //重写AddAttributesToRender方法
protected override void AddAttributesToRender(HtmlTextWriter output)
{
Attributes.Add("confirmationmessage",Message);
base.AddAttributesToRender(output);
} //重写OnPreRender方法
protected override void OnPreRender( EventArgs e )
{
Page.RegisterClientScriptBlock( "WebUIConfirmation", "<script language='javascript' src='" + ScriptPath + "WebUIConfirmation.js" + "'></script>" );
Page.RegisterArrayDeclaration("Page_Confirmations", "'" + ClientID + "'" );
Page.RegisterStartupScript( "WebUIConfirmation Startup", "<script language='javascript' src='" + ScriptPath + "WebUIConfirmationStartup.js" + "'></script>" );
base.OnPreRender(e);
}
}
}