按钮-Button

按钮-Button

按钮添加JaveScript代码

1
按钮-Button
<
asp:Button 
ID
=”Button1″
 runat
=”server”
 Height
=”28px”
 Text
=”点我”
 Width
=”93px”


2
按钮-Buttononmouseover
=”c=this.style.backgroundColor; this.style.backgroundColor=’#00ff99′; this.style.width=’150′;”


3
按钮-Buttononmouseout
=”this.style.backgroundColor=c;this.style.width=’93’;”
 Font-Bold
=”true”
/>

按钮添加属性

按钮-Button
protected
 
void
 Button2_Load(
object
 sender, EventArgs e)
按钮-Button按钮-Button    

按钮-Button
{

按钮-Button        
按钮-Button        Button2.Attributes.Add(
“onmouseover“, “c=this.style.backgroundColor;this.style.backgroundColor=’#00ff99′;“);
按钮-Button        Button2.Attributes.Add(
“onmouseout“, “this.style.backgroundColor=c“);
按钮-Button        Button2.Text 
= DateTime.Now.ToString();
按钮-Button    }

按钮CommandName属性
PS:
三个按钮同时触发button2_Click事件,根据事件惩罚者((Button)sender)的CommandName来判断

按钮-Button
<
asp:Button 
ID
=”Button2″
 runat
=”server”
 CommandName
=”a”
 OnClick
=”Button2_Click”
 Text
=”小明”
 OnLoad
=”Button2_Load”
 
/>

按钮-Button        

<
asp:Button 
ID
=”Button3″
 runat
=”server”
 CommandName
=”b”
 OnClick
=”Button2_Click”
 Text
=”小里”
 
/>
&nbsp;

按钮-Button        

<
asp:Button 
ID
=”Button4″
 runat
=”server”
 CommandName
=”c”
 OnClick
=”Button2_Click”
 Text
=”小王”
 
/>

按钮-Button
protected
 
void
 Button2_Click(
object
 sender, EventArgs e)
按钮-Button按钮-Button    

按钮-Button
{

按钮-Button        
switch (((Button)sender).CommandName)
按钮-Button按钮-Button        
按钮-Button{

按钮-Button            
case “a“:
按钮-Button                lb1.Text 
= ((Button)sender).Text;
按钮-Button                
break;
按钮-Button            
case “b“:
按钮-Button                lb1.Text 
= ((Button)sender).Text;
按钮-Button                
break;
按钮-Button            
default:
按钮-Button                lb1.Text 
= “33333“;
按钮-Button                
break;
按钮-Button        }

按钮-Button
按钮-Button    }

转载于:https://www.cnblogs.com/net123/archive/2007/12/15/996215.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/111060.html原文链接:https://javaforall.net

赞 (0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号