zoukankan      html  css  js  c++  java
  • C#语法基础巩固

    1、protected void Button1_Click(object sender, EventArgs e)

    protected 关键字是一个成员访问修饰符。受保护成员在它的类中可访问并且可由派生类访问 
    void表示该方法没有返回类型
    Button1_Click这是按钮1的点击事件
    object sender表示的是Objece类型的参数
    EventArgs表示的是事件源
     
     
    object sender 触发这个函数发生的对象 
     EventArgs e 事件相关参数数据 你要为一个事件写一个响应函数,你需要什么? 
    1.是谁触发的:你可以把三个按钮的点击事件都指定为一个响应函数,但是你要是做出不同反应怎么办?区分sender看是哪个按钮。
     2.触发的是什么事件,这个事情的详细情况是什么:这里边包含着事件能提供的附属信息 
     可以理解下下面方法中的 e 所起的作用
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
     {
     if (e.Row.RowType == DataControlRowType.DataRow)
     { 
     //删除时的确定
     (e.Row.Cells[6].Controls[0] as LinkButton).Attributes.Add("onclick","return confirm('确定删除?');"); 
     //实现光棒效果 
     e.Row.Attributes.Add("onmouseover","this.bgColor='#ee00ee';");
     e.Row.Attributes.Add("onmouseout", "this.bgColor='#ffffff';"); 
     //如果编辑的索引和当前你选的行的索引相同 
     if (GridView1.EditIndex == e.Row.RowIndex)
     { 
     //找到下拉列表控件(注意是该控件的ID)
     DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList; 
     //(e.Row.DataItem)来获得当前这一行数据所对应的实体类对象 
     Entity entity= (e.Row.DataItem as Entity); //ddl.ClearSelection(); 
     //在下拉列表中找到该对象的学历并选中
     ddl.Items.FindByText(worker.WorkStudyLevel).Selected = true;
     FileUpload fu = e.Row.FindControl("FileUpload1") as FileUpload; 
     //通过属性中杂项找到id
     Image hi = e.Row.FindControl("Image1") as Image; 
     string scriptStr = "SetImage(this.value,'name');"; 
     scriptStr = scriptStr.Replace("name",hi.ClientID); 
     fu.Attributes.Add("onchange", scriptStr); 
     //fu.Attributes.Add("onchange", "SetImage(this.value,'"+hi.ClientID+"');");与上一样
     } 
     } 
     }
  • 相关阅读:
    Python元组、列表、字典
    测试通过Word直接发布博文
    Python环境搭建(windows)
    hdu 4003 Find Metal Mineral 树形DP
    poj 1986 Distance Queries LCA
    poj 1470 Closest Common Ancestors LCA
    poj 1330 Nearest Common Ancestors LCA
    hdu 3046 Pleasant sheep and big big wolf 最小割
    poj 3281 Dining 最大流
    zoj 2760 How Many Shortest Path 最大流
  • 原文地址:https://www.cnblogs.com/ydfq-home/p/5017378.html
Copyright © 2011-2022 走看看