您的位置:首页 > 其它

个人使用控件点滴

2004-09-17 20:23 288 查看
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属性,是无法取得图片时的替代文本。 同样可以使用 onmouseover="b()" onmouseout="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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: