惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
U
Unit 42
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
G
Google Developers Blog
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
A
About on SuperTechFans
Jina AI
Jina AI
量子位
宝玉的分享
宝玉的分享
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
Last Week in AI
Last Week in AI
WordPress大学
WordPress大学
美团技术团队
The Hacker News
The Hacker News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tailwind CSS Blog
博客园 - 司徒正美
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
P
Palo Alto Networks Blog
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
博客园 - 【当耐特】
Spread Privacy
Spread Privacy
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
Vercel News
Vercel News
Martin Fowler
Martin Fowler
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Forbes - Security
Forbes - Security
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Privacy International News Feed
G
GRAHAM CLULEY
The Last Watchdog
The Last Watchdog
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
V2EX - 技术
V2EX - 技术

博客园 - 让心灵去旅行

在Javascript中用command模式模拟多线程,包含注释 项目小结 sql语句性能提高 oracle的异常 简单的消息发送小程序 XP风格进度条 随机抽取不重复的数据 xmlhttp实现无刷新页面 VS.Net 2005中文版下载地址收藏 在线统计与跟踪(新) 简单ocx控件制作方法(原创) 可以双击的DataGrid 权限管理的方案(只有实现思想) 收藏几段SQL Server语句和存储过程(转载) 动态添加和删除行 键盘各键对应的键值 只能输入数值的输入框 操作动态表格的控件 模仿QQ的菜单滚动效果
自己做控件小例子
让心灵去旅行 · 2005-08-02 · via 博客园 - 让心灵去旅行

自己做控件小例子

自己做控件,也很容易。贴出来,给初学的人提供经验

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;

namespace ISDReport.control
{    
    
public class DemoLinkButton:System.Web.UI.WebControls.WebControl,IPostBackEventHandler
    
{    
        
public DemoLinkButton()
        
{
        }

    
        [Bindable(
false),
        Category(
"Appearance"), 
        DefaultValue(
"")] 
        
        
public string Text 
        
{
            
get
            
{
                
string _text = (string)ViewState["Text"];
                
return _text==null?"":_text;
            }

            
set
            
{
                ViewState[
"Text"= value;
            }

        }


        
protected override void OnPreRender(System.EventArgs e)
        
{
             
string scriptClick="<script language='javascript'>function DoOnClick(){"
                 
+((HyperLinkClicked==null)?"":(Page.GetPostBackClientEvent(this,"Clicked"))
                 
+"; return;}</script>");
            Page.RegisterClientScriptBlock(
"OnClicked",scriptClick);
        }


        
protected override void Render(HtmlTextWriter writer)
        
{
            
if(this.Text=="")
            
{
                writer.Write(
"<a href=\"javascript:DoOnClick();\" id=\""+this.ClientID+"\">DemoLinkButton</a>");
            }

            
else{
                writer.Write(
"<a href=\"javascript:DoOnClick();\" id=\""+this.ClientID+"\">"+this.Text+"</a>");
            }

        }


        
public void RaisePostBackEvent(string eventArgument)
        
{
            
if(eventArgument=="Clicked")  HyperLinkClicked(this,System.EventArgs.Empty);
        }
            


        
public delegate void HyperLinkClickedHandle(object sender,System.EventArgs e);
        
public event HyperLinkClickedHandle HyperLinkClicked;

    }

}

posted @ 2005-08-02 11:00  让心灵去旅行  阅读(907)  评论(4)    收藏  举报