遇读写冲突。。。

C#中,由于.net不能及时更新,就会出现以下这种情况:

User已经点开链接在看东西,Admin于此时出于某种原因把把链接的页面删除掉了,此时User如果想在链接的页面里做些什么,如提交之类操作,页面就会出现一大堆错识,这样看起来很不好,我们此时需要提醒User该信息不存在。

解决方法: 在PageLoad事件里写上try...catch,任何异常用catch告诉对方就好了

eg:

  protected void Page_Load(object sender, EventArgs e)
        {
            //获取ID
             string StrID = Server.UrlDecode(Request.QueryString["id"]);

            if (!IsPostBack)
            {
                try
                {
                    if (StrID != null)
                    {
                        UDS.Components.SchoolPublic act = new UDS.Components.SchoolPublic();

                        int intID = Int32.Parse(StrID);

                        string Path = "";

                        DataTable dt = act.GetInfoFileID(intID);

                        TextBoxTitle.Text = dt.Rows[0]["File_Title"].ToString();

                        this.FreeTextBox1.Text = dt.Rows[0]["Summary"].ToString();

                        TextBoxTime.Text = dt.Rows[0]["Up_Time"].ToString();

                        TextBoxMemo.Text = dt.Rows[0]["File_Memo"].ToString();

                        Path = dt.Rows[0]["File_Path"].ToString();

                        if (Path == "")
                        {
                            this.btnDownload.Text = "(没有附件下载)";
                            this.btnDownload.Enabled = false;
                        }
                        else
                        {
                            this.btnDownload.Text = "有附件(请点击下载)";
                        }
                    }
                }
                catch
                {
                    Response.Write("<script language='javascript'>alert('此信息已被删除!');window.location.href='SchPubBrowser.aspx'</script>");
                }
            }

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值