📄 mero.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class mero : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int id = Convert.ToInt32(Request.QueryString["id"]);
// 设置回复标题
titletb.Text = "Ra:" + odb.scr("select title from guest where id=" + id + "");
// 设置页标题
Page.Title = odb.scr("select title from guest where id=" + id + "");
}
}
protected void FormView1_ItemCreated(object sender, EventArgs e)
{//处理图标
int id = Convert.ToInt32(Request.QueryString["id"]);
Image qq = (Image)FormView1.FindControl("Image2");
qq.Visible = odb.img("select qq from guest where id=" + id + "");
//email
Image email = (Image)FormView1.FindControl("Image3");
email.Visible = odb.img("select email from guest where id=" + id + "");
//MSN
Image msn = (Image)FormView1.FindControl("Image4");
msn.Visible = odb.img("select msn from guest where id=" + id + "");
//url
Image url = (Image)FormView1.FindControl("Image5");
url.Visible = odb.img("select url from guest where id=" + id + "");
//如果有密码就不显示内容
Label concent = (Label)FormView1.FindControl("Label4");
Panel dengl = (Panel)FormView1.FindControl("dl");
if (!odb.img("select pwd from guest where id=" + id + ""))
{//如果没密码的话就直接显示内容以及需要的回复
concent.Text = Server.HtmlDecode(odb.scr("select concent from guest where id=" + id + "")).ToString();
if (Convert.ToInt32(odb.scr("select count(*) from [read] where lid=" + id + "")) > 0)
{//如果有回复的话就把回复panel以及下面的东西都找出来,然后绑上数据,显示出来
Panel re = (Panel)FormView1.FindControl("Panel1");
re.Visible = true ;
DataList read = (DataList)FormView1.FindControl("DataList2");
read.DataSource = odb.ds("select * from [read] where lid=" + id + "");
read.DataBind();
}
}
else
{//如果有密码就把内容隐去,出现登陆项
if (Session["fk"] != null || Session["qx"] != null)
{
concent.Text = Server.HtmlDecode(odb.scr("select concent from guest where id=" + id + "")).ToString();
if (Convert.ToInt32(odb.scr("select count(*) from [read] where lid=" + id + "")) > 0)
{//如果有回复的话就把回复panel以及下面的东西都找出来,然后绑上数据,显示出来
Panel re = (Panel)FormView1.FindControl("Panel1");
re.Visible = true ;
DataList read = (DataList)FormView1.FindControl("DataList2");
read.DataSource = odb.ds("select * from [read] where lid=" + id + "");
read.DataBind();
}
}
else
{
dengl.Visible = true;
concent.Visible = false;
}
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int lid = Convert.ToInt32(Request.QueryString["id"]);
string name = Server.HtmlEncode(nametb.Text.ToString().Replace("'", "!"));
string title = Server.HtmlEncode(titletb.Text.ToString().Replace("'", "!"));
string concent = Server.HtmlEncode(concentdx.Text.ToString().Replace("'", "!"));
DateTime dtt = DateTime.Now;
string que = "INSERT INTO [read] ([lid], [name], [title], [concent], [dtt]) VALUES ('" + lid + "','"+name+"','" + title + "','" + concent + "','" + dtt + "')";
if (odb.insert(que))
{//调用ODB类的插入方法,并把SQL语句作为参数传给类,让他帮助完成
Response.Redirect("cg.aspx?cg=b&id="+lid);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox pwd = (TextBox)FormView1.FindControl("dlpwd");
Label id = (Label)FormView1.FindControl("iidd");
if (odb.scr("select [pwd] from [guest] where id=" + id.Text + "").ToString() == pwd.Text.ToString())
{
Session["fk"] = pwd.Text.ToString();
Label concent = (Label)FormView1.FindControl("Label4");
Panel dengl = (Panel)FormView1.FindControl("dl");
dengl.Visible = false;
concent.Visible = true;
if (Convert.ToInt32(odb.scr("select count(*) from [read] where lid=" + id.Text + "")) > 0)
{//如果有回复的话就把回复panel以及下面的东西都找出来,然后绑上数据,显示出来
Panel re = (Panel)FormView1.FindControl("Panel1");
re.Visible = true;
DataList read = (DataList)FormView1.FindControl("DataList2");
read.DataSource = odb.ds("select * from [read] where lid=" + id.Text + "");
read.DataBind();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -