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;
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;
{
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;
{
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-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'].item(i).text=txt;
document.Form1.all['ListBox1'].selectedIndex=i-1;
}
}
}
}
Trackback: http://tb.blog.youkuaiyun.com/TrackBack.aspx?PostId=108263