|
首页 | 名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
比较好看吧. using System;
using System.ComponentModel; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; namespace ClingingBoy { [DefaultProperty("text"), ToolboxData("<{0}:Cingmenu runat=server>")] /// /// cingmenu 的摘要说明 /// public class Cingmenu:WebControl { #region 定义变量 private string text = ""; private string href = ""; private string width = "20%"; private string height = ""; private string fontfamily = "宋体"; private string fontsize = "12px"; private string target = "_self"; private bool displayPipe = true; #endregion #region 构造函数 public Cingmenu():base(HtmlTextWriterTag.Div) { } #endregion #region 定义属性 [Description("该属性用于表示控件显示的文字内容"), Bindable(true), Category("Appearance"), DefaultValue("")] public string Text { get { return text; } set { text = value; } } [Description("该属性用于表示控件的链接地址"), Bindable(true), Category("Appearance"), DefaultValue("")] public string Href { get { return href; } set { href = value; } } [Description("该属性用于表示控件显示的文字大小"), Bindable(true), Category("Appearance"), DefaultValue("12px")] public string FontSize { get { return fontsize; } set { fontsize = value; } } [Description("该属性用于表示控件显示的文字字体类型"), Bindable(true), Category("Appearance"), DefaultValue("宋体")] public string FontFamily { get { return fontfamily; } set { fontfamily = value; } } [Description("该属性用于表示控件的链接的目标框架"), Bindable(true), Category("Appearance"), DefaultValue("宋体")] public string Target { get { return target; } set { target = value; } } [Description("该属性用于表示控件是否显示分隔符 | "), Bindable(true), Category("Appearance"), DefaultValue("true")] public bool DisplayPipe { get { return displayPipe; } set { displayPipe = value; } } #endregion protected override void AddAttributesToRender(HtmlTextWriter output) { //定义控件div的样式style="WHITE-SPACE: nowrap;BORDER-TOP: #999 1px solid;BACKGROUND: #f1f1f1; PADDING-BOTTOM: 2px; PADDING-TOP: 1px; BORDER-BOTTOM: #999 1px solid" output.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "#f1f1f1"); output.AddStyleAttribute("white-space", "nowrap"); output.AddStyleAttribute("BORDER-TOP", "#999 1px solid"); output.AddStyleAttribute("BORDER-BOTTOM", "#999 1px solid"); output.AddStyleAttribute("PADDING-BOTTOM", "2px"); output.AddStyleAttribute("PADDING-TOP", "2px"); output.AddStyleAttribute("WIDTH", width); output.AddStyleAttribute("HEIGHT", height); base.AddAttributesToRender(output); } /// /// 呈现控件的方式RenderContents /// protected override void RenderContents(HtmlTextWriter output) { //定义样式 output.AddStyleAttribute(HtmlTextWriterStyle.Width, "10px"); output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fontsize); output.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, fontfamily); output.RenderBeginTag(HtmlTextWriterTag.Span); //定义样式 ////onmouseover="this.style.cssText=’color:black;text-decoration:none;BORDER: #999 1px s olid; DISPLAY: block; PADDING-RIGHT: 6px; PADDING-LEFT: 6px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px;BACKGROUND: #ccc; ’" //style="color:black;text-decoration:none;BORDER: #f1f1f1 1px solid;DISPLAY: block; PADDING-RIGHT: 6px; PADDING-LEFT: 6px; PADDING-BOTTOM: 2px;PADDING-TOP: 2px;" href="http://localhost">文字内容 output.AddStyleAttribute(HtmlTextWriterStyle.Color, "black"); output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute("BORDER", "#f1f1f1 1px solid"); output.AddStyleAttribute("DISPLAY", "block"); output.AddStyleAttribute("PADDING-RIGHT", "6px"); output.AddStyleAttribute("PADDING-LEFT", "6px"); output.AddStyleAttribute("PADDING-BOTTOM", "2px"); output.AddStyleAttribute("PADDING-TOP", "2px"); output.AddAttribute("onmouseout", "this.style.cssText=’color:black;text-decoration:none;BORDER: #f1f1f1 1px solid; DISPLAY: block; PADDING-RIGHT: 6px;PADDING-LEFT: 6px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px; ’"); output.AddAttribute("onmouseover", "this.style.cssText=’color:black;text-decoration:none;BORDER: #999 1px solid; DISPLAY: block; PADDING-RIGHT: 6px; PADDING-LEFT: 6px; PADDING-BOTTOM: 2px; PADDING-TOP: 2px;BACKGROUND: #ccc; ’"); //定义属性Href,Target output.AddAttribute(HtmlTextWriterAttribute.Href, href); output.AddAttribute(HtmlTextWriterAttribute.Target, target); output.RenderBeginTag(HtmlTextWriterTag.A); output.Write(text); if (displayPipe) { output.AddStyleAttribute(HtmlTextWriterStyle.Color, "#a9a9a9"); output.AddStyleAttribute("FONT", "70%"); output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, fontsize); output.AddStyleAttribute("PADDING-RIGHT", "3px"); output.AddStyleAttribute("PADDING-LEFT", "3px"); output.RenderBeginTag(HtmlTextWriterTag.Span); output.Write("|"); output.RenderEndTag(); } else { output.RenderBeginTag(HtmlTextWriterTag.Span); output.Write(" "); output.RenderEndTag(); } output.RenderEndTag(); output.RenderEndTag(); //定义分隔符及样式 //使用默认逻辑来呈现子控件 base.RenderContents(output); } } } 前台的 @ Page Language="C#" %>
@ Register Assembly="CingMenu" Namespace="ClingingBoy" TagPrefix="cc2" %> 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> <TABLE id="Table5" border="0" cellpadding="0" cellspacing="0" style="height: 2px"> <TR> <TD style="height: 26px"> <cc2:Cingmenu id="CustomControl1" DisplayPipe="true" runat="server" Target="_blank" Text="微软中国" Href="http://www.clingingboy.com">cc2:Cingmenu> TD> <TD style="height: 26px"> <cc2:Cingmenu id="Webcustomcontrol1" DisplayPipe="true" runat="server" Target="_blank" Text="微软中国" Href="http://www.clingingboy.com">cc2:Cingmenu> TD> <TD style="height: 26px"> <cc2:Cingmenu id="Webcustomcontrol2" DisplayPipe="true" runat="server" Target="_blank" Text="微软中国" Href="http://www.clingingboy.com">cc2:Cingmenu> TD> <TD style="height: 26px"> <cc2:Cingmenu id="Webcustomcontrol3" DisplayPipe="false" runat="server" Target="_blank" Text="微软中国" Href="http://www.clingingboy.com">cc2:Cingmenu> TD> TR> TABLE> DIV> form> body> html> 返回类别: Flash教程 上一教程: Flash动态遮罩高级教程 下一教程: 用flash制作简朴拼图游戏 您可以阅读与"开发类似微软中国导航条的控件"相关的教程: · Flash MX 2004实例制作视频教程:导航条的制作 · 韩国导航条解析 · FLASH:韩国导航条解析 · flash 避开微软新ActiveX控件升级的方式 · Flash游戏开发系列一:游戏中的敌人(4) |
快精灵印艺坊 版权所有 | 首页会员中心在线印刷在线编辑付款方式索取样品设计指南连锁门店 |