慧云科技 > 首页 > 文章详情

奥杰cms源码 - CommentAdd

本文来源:网站建设-网站制作|网络营销专家慧云科技-

抢滩登陆

2009-7-17 17:01:26

using System;
using System.Data;
using System.Collections;
using System.Web;
using System.Web.UI;
using BoyunBase;
using SiteCore;

public partial class Part_CommentAdd : System.Web.UI.UserControl
{
    private PartAccess pAcc = null;
    private bool isSettingReady = false;
    private string ArticleId = "";
    private string userName = "";

    protected void Page_Load( object sender, EventArgs e )
    {
        try {
            ArticleId = Todo.Get( "aid", Request );
            userName = Todo.Get( "User", Session );
            if( userName == "" ) userName = "游客";

            pAcc = new PartAccess( this );
            PartAccess pAcs = new PartAccess( this );
            if( !pAcs.IsReady ) return;

            if( !IsPostBack ) {
                int mLen = Math.Abs( pAcc.GetSettingInt( "MaxLength", 150 ) ); // Todo.GetInt( "MaxLength", nvCol, 150 ) );
                txtContent.Attributes.Add( "onkeypress", "if (this.value.length>=" + mLen + "){event.returnValue=false}" );
            }
            isSettingReady = true;

        } catch( Exception ex ) {
            Todo.DebugOut( "[Part_CommentAdd.Page_Load] 加载异常:" + ex.Message );
        }
    }

    protected void btnSubmit_Click( object sender, EventArgs e )
    {
        string cont = txtContent.Value.Trim();
        string title = tbTitle.Value.Trim();
        tbTitle.Value = "";
        txtContent.Value = "";

        if( !isSettingReady || ArticleId == "" ) {
            Todo.DebugOut( "[Part_CommentAdd.btnSubmit_Click] 参数错误 isSettingReady=" + isSettingReady + "   ArticleId=" + ArticleId );
            return;
        }
        if( cont == "" ) {
            Todo.DebugOut( "[Part_CommentAdd.btnSubmit_Click] 用户输入为空!" );
            return;
        }

        title = title.Replace( ",", "," );
        cont = cont.Replace( "\r\n", "<br/>" );
        cont = cont.Replace( ",", "," );
        cont = Server.UrlEncode( cont );
        cont = Server.UrlDecode( cont );

        string columnName = "ArticleId,UserName,Content,Title";
        string columnValue = ArticleId + "," + userName + "," + cont + "," + title;

        ContentAccess ca = new ContentAccess( this, "TableName" );
        bool isOK = ca.Write( "[*]", columnName, columnValue );

        if( !isOK ) {
            Todo.DebugOut( "[Part_CommentAdd.btnSubmit_Click] 写入数据库失败" );
            return;
        }
        string PageUrl = pAcc.GetSetting( "ListPagePath" );
        if( PageUrl != "" ) {
            PageUrl += ("?aid=" + ArticleId);
            try {
                Server.Transfer( PageUrl );
            } catch( Exception ex ) { Todo.DebugOut( "[Part_CommentAdd.btnSubmit_Click] 页面跳转出现异常:" + ex.Message ); }
        } else {
            PageUrl = Request.Path;
            PageUrl = PageUrl.Substring( PageUrl.IndexOf( "/" ) );
        }
    }
}


RSS订阅| 关于我们| 网站地图| 加入项目| 法律条款| 友情链接| Firefox| Sitemap| 网站统计

全国免费咨询热线:400-600-6495 优惠活动咨询电话:021-62278496 Email:ajaxcms@yahoo.cn

上海慧云信息科技有限公司版权所有 2006-2009 沪ICP备09038165号

本站关键词:网站建设 高品质网站建设