请大神求救!把下面的ASP.NET代码逐行注释一下。 5

protectedvoidPage_Load(objectsender,EventArgse){if(Session["username"]!=null)//判断用户是否... protectedvoid Page_Load(object sender, EventArgs e)
{
if(Session["username"] != null) //判断用户是否登录
{
if(!Page.IsPostBack)//若登录,加载页面
{
BindProvince();
BindCity();
BindArea();
}
string username =Session["username"].ToString();//获取登录用户的用户名
Users u = newUsersManager().SelectByUserName(username);
Label2.Text = u.Id;
}
else
{ //当前用户没有登录的时候,转到登陆页面让用户先登录再发布房源信息
Response.Write("<ScriptLanguage=JavaScript>alert('请先登录!');</Script>");
Response.Redirect("Login.aspx");
}
}
protectedvoid btnpublish_Click(object sender, EventArgs e)//发布房源
{
stringtitle = txtTitle.Text.Trim();
stringaddress = txtAddress.Text.Trim();
stringprovince = ddlProvince.SelectedItem.Text;
stringcity = ddlCity.SelectedItem.Text;
stringregion = ddlArea.SelectedItem.Text;
stringrentway = RadioButtonList1.Text;
stringroom = txtRoom.Text.Trim();
stringhall = txtHall.Text.Trim();
stringtoilet = txtToilet.Text.Trim();
stringstorey = txtStorey.Text.Trim();
stringstoreyall = txtStoreyAll.Text.Trim();
stringhousetype = dropHtype.Text;
stringdecoration = dropHDecoration.Text;
stringaspect = dropHaspect.Text;
stringarea = txtArea.Text.Trim();
stringrental = txtRent.Text.Trim();
stringmethod = dropMethod.Text;
stringstatus = Label1.Text.Trim();
stringuserid = Label2.Text.Trim();
stringallocation = "";//获取CheckBoxList选中的房源配置信息
for (int i= 0; i < CheckBoxList1.Items.Count; i++)
{
if(CheckBoxList1.Items[i].Selected)
{
allocation+= CheckBoxList1.Items[i].Value + " ";
}
}
string filepath =this.FileUpload1.PostedFile.FileName; //图片
stringpicture = filepath.Substring(filepath.LastIndexOf("\\") + 1);
if(Path.GetExtension(filepath) == ".jpg" || Path.GetExtension(filepath)== ".png" || Path.GetExtension(filepath) == ".tmp" ||Path.GetExtension(filepath) == ".gif")
{
stringsavefile = Server.MapPath("~/") + "picture\\" + picture;
if(File.Exists(savefile))
{
savefile = Server.MapPath("~/") + "picture\\" +System.DateTime.Now.ToString().Replace(":","-").Replace("/", "-") + "data" +Path.GetExtension(filepath);
}
this.FileUpload1.PostedFile.SaveAs(savefile);
}
else{Response.Write("<script>alert('只能上传jpg、tmp、gif、png格式的图片');</script>");
}
Model.HouseInfo hi =new Model.HouseInfo(title, address, province, city, region, rentway, room,hall, toilet, storey, storeyall, housetype, decoration, aspect, area, rental,method, allocation, picture, status, userid);
bool b1 =new BLL.HouseInfoManager().Insert(hi);
stringtelephone = this.txtPhone.Text.Trim();
stringlinkman = this.txtLinkman.Text.Trim();
Model.Linkway lk = newModel.Linkway(userid,linkman,telephone);
bool b2 =new BLL.LinkwayManager().InsertLinkway(lk);
Response.Redirect("HomePageSkip.aspx");
}
展开
 我来答
清净脦自在
2015-04-24 · 超过33用户采纳过TA的回答
知道答主
回答量:94
采纳率:50%
帮助的人:24万
展开全部
开始是load方法 判断了一下用户是否登录和是否是第一次加载;第二个方法是按钮的触发事件,提交的 获取页面信息存库,接着刷新了一下数据 并显示到页面;逐行。。。。感觉好可爱的想法
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式