
说明:打开页面时只显示第一个注册表格,当你点击提交时,就会显示第二确认表格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 ="格式错误,请从新上传";
}
}
}