using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str1 = "server=.;database=zhuce;integrated security=true";
SqlConnection cn = new SqlConnection();
cn.ConnectionString = str1;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select [name] from suozaibumen";
cmd.Connection = cn;
cn.Open();
SqlDataReader myrd = cmd.ExecuteReader();
ListItem li = null;
int i = 1;
while (myrd.Read())
{
li = new ListItem(myrd.GetString(0), i.ToString());
DropDownList1.Items.Add(li);
i += 1;
}
cn.Close();
}
protected void btn_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("\t");
sb.Append("昵称:");
sb.Append(this.username.Text);
sb.Append("\t");
sb.Append("性别:");
if (Radiobtnman.Checked)
{
sb.Append("男");
}
else
{
sb.Append("女");
}
sb.Append("\t");
sb.Append("所在部门:");
sb.Append(this.DropDownList1.SelectedItem.Text);
sb.Append("\t");
sb.Append("爱好:");
this.Response.Write(this.CheckBoxList1.SelectedValue);
if (txtmail.Text == "")
{
Response.Redirect("请输入E-mail地址");
}
if (txtmail.Text.IndexOf('@') == 0 || txtmail.Text.IndexOf('.') == -1 || txtmail.Text.IndexOf('@') == -1 || txtmail.Text.IndexOf("@ ") > txtmail.Text.Length - 6)
{
Response.Redirect("邮箱格式不正确,请重新输入!");
}
sb.Append("\t");
sb.Append("E-mail:");
sb.Append(this.txtmail.Text);
string birthday = this.txtbirthday.Text;
string str = @"^{4}-\t{2}-\t{2}$";
if (Regex.IsMatch(str, birthday))
{
Response.Redirect("生日格式不正确,请重新输入!");
}
sb.Append("\t");
sb.Append("生日:");
sb.Append(this.txtbirthday.Text);
string filename = this.File1.PostedFile.FileName;
filename = DateTime.Now.Ticks.ToString() + filename.Substring(filename.LastIndexOf("."));
this.File1.PostedFile.SaveAs(Server.MapPath("upload") + "\\" + filename);
sb.Append("\t");
sb.Append("头像:");
sb.Append("<img height='40' width='40' src=\"upload/" + filename + "\" />");
sb.Append("\t");
sb.Append("个人简介:");
sb.Append(this.txtjianjie.Text);
this.div1.InnerHtml = sb.ToString();
}
}