当前位置:编程学习 > C#/ASP.NET >>

自定义Web控件开发求大神帮帮

 好久没来MSDN了 各位技术同仁可好呀..

 最近由于项目上需要很多功能性的组件 所有想做一些webControl,其实用户控件也行,只是想做成 dll 可以从工具箱中拖出来那种,使用也方便.但是没啥资料,网上也没找到多少 ,谁有给小弟介绍一点 或者有相关资料 发我邮箱 47239898@qq.com 先谢过了 Web 控件 技术 --------------------编程问答-------------------- 1、设计显示
 namespace OpenFlashChart
{
    public class ChartControlDesigner : ControlDesigner
    {
        public override string GetDesignTimeHtml()
        {
            string errorDesignTimeHtml;
            StringBuilder builder = new StringBuilder();
            try
            {
                OpenFlashChartControl component = (OpenFlashChartControl)base.Component;
                OpenFlashChartControl chart = component;
                //string _imgUrl = p.ClientScript.GetWebResourceUrl(typeof(ChartControlDesigner), "OpenFlashChart.backImg.jpg");
                builder.AppendFormat("<div style='width:{0};height:{1};'>", chart.Width, chart.Height);
                builder.Append("<span style=\"font-size:16px;position:absolute;\">Open Flash Chart Control</span>");
                builder.AppendFormat("<img src=\"{0}\"/>", chart.Parent.Page.ClientScript.GetWebResourceUrl(typeof(OpenFlashChartControl), "OpenFlashChart.backImg.jpg"));
                builder.Append("</div>");
                errorDesignTimeHtml = this.CreatePlaceHolderDesignTimeHtml(builder.ToString());
            }
            catch (Exception e)
            {
                errorDesignTimeHtml = this.GetErrorDesignTimeHtml(e);
            }
            return errorDesignTimeHtml;
        }
        protected override string GetErrorDesignTimeHtml(Exception e)
        {
            string instruction = string.Format("Exception:{0}",  e.Message );
            return this.CreatePlaceHolderDesignTimeHtml(instruction);
        }
    }
}

引用设置

[assembly: WebResource("OpenFlashChart.open-flash-chart.swf", "application/x-shockwave-flash")]
[assembly: WebResource("OpenFlashChart.swfobject.js", "text/javascript")]
[assembly: WebResource("OpenFlashChart.backImg.jpg", "image/jpg")]
[assembly: WebResource("OpenFlashChart.OpenFlashChartControl.bmp", "image/bmp")]
namespace OpenFlashChart
{
    [System.Drawing.ToolboxBitmap(typeof(OpenFlashChart)), Designer(typeof(ChartControlDesigner)), Description("Chart control for open flash chart"), ToolboxData("<{0}:OpenFlashChartControl runat=\"server\" ></{0}:OpenFlashChartControl>")]
    public class OpenFlashChartControl : Control 

显示效果 
 

2 、工具上的ico
[assembly: WebResource("OpenFlashChart.OpenFlashChartControl.bmp", "image/bmp")]

  [System.Drawing.ToolboxBitmap(typeof(OpenFlashChart)), Designer(typeof(ChartControlDesigner)), Description("Chart control for open flash chart"), ToolboxData("<{0}:OpenFlashChartControl runat=\"server\" ></{0}:OpenFlashChartControl>")]
    public class OpenFlashChartControl : Control

经 过多次测试,ICO的名称必须和控件名称一致 --------------------编程问答-------------------- 博客园上有很多 usercontrol搜索 --------------------编程问答-------------------- 这里不是MSDN,楼主你走错方向了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,