第二天ASP.NET学习总结

    技术2022-05-11  69

    1.textBox1.BackColor   =   System.Drawing.Color.Red

    2.TextMode="multiline"时可以取代html中的textarea

    3.RadioButton控件中,只需要将GroupName设置为相同就成了RadioButtonlist(该控件的格式:<asp:RadioButtonList  ID="radlColors"  AutoPostBack="True"  OnSelectedIndexChanged="radlColors_SelectedIndexChanged"  Runat="Server" >  <asp:ListItem text="Red"  value="R" />  <asp:ListItem text="Green" value="G" />  <asp:ListItem text="Blue" value="B" /></asp:RadioButtonList>)4.RadioButtonlist数据绑定实例:后台:void Page_Load(Object sender, EventArgs e) {  ArrayList  colArrayList = new ArrayList();  if (! IsPostBack )   {    colArrayList.Add( "Red" );    colArrayList.Add( "Blue" );    colArrayList.Add( "Green" );    radlFavoriteColor.DataSource = colArrayList;    radlFavoriteColor.DataBind();  }}前台:<asp:RadioButtonList  ID="radlFavoriteColor"  Runat="Server"/>

    4.RadioButton的两种事件响应方法:1.OnCheckedChanged="City_Changed" (适合搭配属性AutoPostBack="True") 

    2.最后botton提交OnClick="Button_Click"(投票用这个好!) 

    5.强制转化类型,例如str转化成long,则long.Parse(strID),一个新闻详细页面总是提示request["id"]类型不一样,一个解决方案如下: private string strID = "";    protected void Page_Load(object sender, EventArgs e)    {        strID = Request["id"];        GetNews();    }


    最新回复(0)