protected void ddlColor_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ddlColor.SelectedValue == "紅色")
this.txtMsg.ForeColor = Color.Red;//字型顏色
this.txtMsg.Font.Name= "仿宋_GB2312";//設定字型
this.txtMsg.Font.Size = FontUnit.Point(12);//字型大小
}
else if (this.ddlColor.SelectedValue == "黑色")
this.txtMsg.ForeColor = Color.Black;
this.txtMsg.Font.Size = FontUnit.Point(15);
this.txtMsg.Font.Name = "華文新魏";
else if (this.ddlColor.SelectedValue == "藍色")
this.txtMsg.ForeColor = Color.Blue;
this.txtMsg.Font.Size = FontUnit.Point(20);
this.txtMsg.Font.Name = "方正舒體";
else if (this.ddlColor.SelectedValue == "綠色")
this.txtMsg.ForeColor = Color.Green;
this.txtMsg.Font.Size = FontUnit.Point(25);
this.txtMsg.Font.Name = "方正姚體";
注意:設定DropDownList 的AutoPostBack為true;
protected void ddlColor_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ddlColor.SelectedValue == "紅色")
{
this.txtMsg.ForeColor = Color.Red;//字型顏色
this.txtMsg.Font.Name= "仿宋_GB2312";//設定字型
this.txtMsg.Font.Size = FontUnit.Point(12);//字型大小
}
else if (this.ddlColor.SelectedValue == "黑色")
{
this.txtMsg.ForeColor = Color.Black;
this.txtMsg.Font.Size = FontUnit.Point(15);
this.txtMsg.Font.Name = "華文新魏";
}
else if (this.ddlColor.SelectedValue == "藍色")
{
this.txtMsg.ForeColor = Color.Blue;
this.txtMsg.Font.Size = FontUnit.Point(20);
this.txtMsg.Font.Name = "方正舒體";
}
else if (this.ddlColor.SelectedValue == "綠色")
{
this.txtMsg.ForeColor = Color.Green;
this.txtMsg.Font.Size = FontUnit.Point(25);
this.txtMsg.Font.Name = "方正姚體";
}
}
注意:設定DropDownList 的AutoPostBack為true;