个人使用控件点滴

1, DataGrid中
Button 控件的单击,先响应Click,后Command 事件。通过e.CommandName;判断哪个按钮
 
加入模版列的按钮会将其click事件反升到 DataGrid1_ItemCommand 事件
 
2,TextBox1 类似“搜索”,回车执行:
 
AutoPostBack="True"
在TextBox1_TextChanged()事件中作处理

 
2, 多个TextBox 或 Button  响应同一事件:
修改事件名:
this.TextBox1.TextChanged += new System.EventHandler( TextChanged); 
this.TextBox2.TextChanged += new System.EventHandler( TextChanged);
 
定义:
  private void TextChanged(object sender, System.EventArgs e)
  {   
    //区分控件的方法
   string id=((TextBox)sender).ID;
   //string b=((Button)sender).CommandName; 
    switch(id)
    {
    }

  }
 
TextBox的Wrap属性,决定是否自动换行。
 
 
3,ImageButton1可以作为图像地图使用,
   private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  {
   int a=e.X;
   int b=e.Y;
    //可以得到鼠标点击的位置,执行不同的操作。
  }
 
  AlternateText属性,是无法取得图片时的替代文本。
 
  同样可以使用  οnmοuseοver="b()" οnmοuseοut="h()"  动态改变外观。
 
 
4,HyperLink 控件
文本链接:text
图片链接:ImageUrl
若同时设置时,ImageUrl,具有较高的优先权,此时,text作为提示文本出现。
 
 
 
5,在客户端javascript里操作服务端控件:
this.Button1.Attributes.Add("onclick","return upchang();");
 
function upchang()
{
 var i= document.Form1.all['ListBox1']. selectedIndex;
 if(i>0)
 {
  var val=document.Form1.all['ListBox1']. item(i-1 ).value;
  var txt=document.Form1.all['ListBox1'].item (i-1 ).text;
 
  document.Form1.all['ListBox1'].item(i-1).value=document.Form1.all['ListBox1'].item(i).value;
  document.Form1.all['ListBox1'].item(i-1).text=document.Form1.all['ListBox1'].item(i).text;
 
  document.Form1.all['ListBox1'].item(i).value=val;
  document.Form1.all['ListBox1'].item(i).text=txt;
 
  document.Form1.all['ListBox1'].selectedIndex=i-1;
 }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值