說明:打開頁面時只顯示第一個註冊表格,當你點擊提交時,就會顯示第二確認表格ide
執行代碼以下: this
public partial class _Default : System.Web.UI.Page 3d
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
this.Label1.Text = this.TextBox1.Text;//獲取用戶名
this.Label2.Text = this.TextBox2.Text;//獲取密碼
this.Panel1.Visible = true;//提交後顯示確認信息
string c1;
if (this.RadioButton1.Checked == true)//獲取性別
{
c1 = "男";
}
else
{
c1 = "女";
}
this.Label4.Text = c1;
this.Label5.Text = this.DropDownList1.SelectedItem.Text;
string s1, s2, s3, s4;//獲取愛好
if (this.CheckBox1.Checked == true)
{
s1 = "玩遊戲,";
}
else
{
s1 = "";
}
if (this.CheckBox2.Checked == true)
{
s2 = "聊QQ,";
}
else
{
s2 = "";
}
if (this.CheckBox3.Checked == true)
{
s3 = "旅遊,";
}
else
{
s3 = "";
}
if (this.CheckBox4.Checked == true)
{
s4 = "探險,";
}
else
{
s4 = "";
}
this .Label6.Text =s1+s2+s3+s4;
string mc = this.FileUpload1.FileName;//獲取文件名稱
this.Label7.Text = mc;
string dx = this.FileUpload1.PostedFile.ContentLength.ToString();//獲取文件大小,以字節爲單位
this.Label3.Text = dx;
string lx = this.FileUpload1.PostedFile.ContentType;//獲取文件類型
this.Label8.Text = lx;
string lj = Server.MapPath("zp") + "\\" + mc;//獲取文件路徑
string kzm = mc.Substring(mc.LastIndexOf(".") + 1);//獲取文件擴展名
if (kzm == "gif" || kzm == "jpg" || kzm == "bmp" || kzm == "png")//判斷格式
{
FileUpload1.SaveAs(lj);//執行提交
this.Label9.Text = "";
}
else
{
this .Label9 .Text ="格式錯誤,請從新上傳";
}
}
}