WebUI/Admin/Conctrl/AddBlog.ascx.cs
(完整代码) 1KBusing 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;
using H.Model;
using H.BLL;
public partial class Admin_Conctrl_AddBlog : System.Web.UI.UserControl
{
int id;
protected void Page_Load(object sender, EventArgs e)
{
id = Convert.ToInt32(Request.QueryString["id"]);
if (!IsPostBack)
{
DropDownList1.DataSource = BlogTypeManager.GetAll();
DropDownList1.DataBind();
}
if (!IsPostBack&&id!=0)
{
Blog b = BlogManager.GetByID(id);
TextBox1.Text = b.Title;
TextBox2.Text = b.Text;
DropDownList1.Items.FindByValue(b.Type.Id.ToString()).Selected = true;
CheckBox1.Checked = b.Order == 0 ? true : false;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Blog b = new Blog ();
b.Intime = DateTime.Now;
b.Text = TextBox2.Text;
b.Title = TextBox1.Text;
b.Order = CheckBox1.Checked ? 0 : 1;
int type = Convert.ToInt32(DropDownList1.SelectedValue);
b.Id = id;
try
{
if (id == 0)
BlogManager.Add(b,type);
else
BlogManager.Edit(b, type);
Response.Redirect("more.aspx?type=" + type);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
