NewsDetail.aspx.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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;
using System.Linq;
using System.Data.SqlClient;
// 下载于www.51aspx.com 
public partial  class NewsDetail : System.Web.UI.Page
{
    public string newsContent = "";
    int newsid = 0;
    SqlData da = new SqlData();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uname"] == null)
        {
            Response.Redirect("Default.aspx");
            return;
        }
        newsid = Convert.ToInt32("" + Request.QueryString["id"]);
        if (!IsPostBack)
        {
            string sqlString = "select * from tb_News";
            DataSet ds = da.datesetExecute(sqlString, "tbNews");
            DataRow[] row = ds.Tables["tbNews"].Select("id=" + newsid);

            foreach (DataRow rs in row)
            {
                this.labTitle.Text = rs["title"].ToString();
                newsContent = rs["content"].ToString();
            }
        }
    }

    public string GetContent()
    {
        string str = "";
        str = newsContent;
        return str;
    }


    protected void linkbut_Click(object sender, EventArgs e)
    {
        var NewsId = newsid;
        string sql = @"select count(1) from shoucang where userid = " + Session["uname"] + " and newsid=" + newsid;
        var count = "" + da.ExecuteScalar(sql);
        if (count != "0")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<Script language='javascript'>alert('已经收藏,不能再次收藏!');document.location=document.location;</script>");
            return;
        }
        sql = "insert into shoucang([newsid],[userid]) values(" + newsid + ",'" + Session["uname"] + "')";
        bool f = da.ExecuteSQL(sql);
后面还有 7 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。