| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1804 人关注过本帖
标题:调试错误了。谁熟悉 NVelocity 模板引擎,小弟感激不尽。最好是能帮我远程调 ...
取消只看楼主 加入收藏
qq745748561
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-6-8
收藏
 问题点数:0 回复次数:0 
调试错误了。谁熟悉 NVelocity 模板引擎,小弟感激不尽。最好是能帮我远程调试一下!
图片附件: 游客没有浏览图片的权限,请 登录注册
程序代码:
后台代码using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace tengfeikeji.admin
{
    /// <summary>
    /// Insert 的摘要说明
    /// </summary>
    public class Insert : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            //获取Action是否是发布新闻还是编辑新闻
             string Action = context.Request["Action"];
            if (Action=="fabu")
              {
             //在发布新闻里面,如果tijiao不为空的话 就是添加信息
            if (!string.IsNullOrEmpty(context.Request["tijiao"]))
            {
                string Name = context.Request["Name"];
                int Category = Convert.ToInt32(context.Request["Category"]);
                string Content = context.Request["content"];
                Sqlhelper.ExecuteNonQuery("insert into T_xinwen(Name,Content,DataTime,categoryID) values(@Name,@Content,@DataTime,@Category)", new SqlParameter("@Name", Name), new SqlParameter("@Content", Content), new SqlParameter("@DataTime", DateTime.Now.ToString()), new SqlParameter("@Category", Category));
                context.Response.Redirect("Index.ashx");
            }
            else
            {
              DataTable dt = Sqlhelper.ExecuteDataTable("select * from T_category");
              var data = new { post = dt.Rows, Action = "fabu", title = new { Name="发布新闻"} };
            string html = CommHelper.ReqHtml("Admin/Insert.htm", data);
            context.Response.Write(html);
            }
          }
          else if (Action == "xiugai")
          {
              if (string.IsNullOrEmpty(context.Request["tijiao"]))
              {
                  string Id = context.Request["Id"];
                  DataTable dt = Sqlhelper.ExecuteDataTable(@"select p.Id as Id, p.Name as Name,k.Name as leibie,
       p.Content as Content from T_xinwen p left join T_category k 
      on p.categoryId=k.Id where p.Id=@Id"
                      , new SqlParameter("@Id", Id));
                  DataTable leibie = Sqlhelper.ExecuteDataTable("select * from T_category");
                  DataRow dr = dt.Rows[0];
                  var data = new { shuju = dr, Action = "xiugai", post = leibie.Rows, title = new { Name = "修改新闻" } };
                  string Html = CommHelper.ReqHtml("Admin/Insert.htm", data);
                  context.Response.Write(Html);
              }
              else
              {
                        
              }
          }
          else
          {

              context.Response.Write("<srcript>alert('动作不能为空!')</script>");

          }
          
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}前台代码#parse("/Admin/Head.htm")
<script type="text/javascript" src="../CSS/ckeditor/ckeditor.js"></script>
<form action="/admin/insert.ashx" method="post" enctype="multipart/form-data">
<input type="hidden"  name="Action" value="$Data.Action"/>
<p>新闻标题:<input type=text name="Name" value="$Data.shuju.Name" />    </p>
<p>新闻类别:<select name="Category">
#foreach($leibie in $Data.post)
<!--#if(Data.shuju.leibie==$leibie.Name)-->
<option value="$leibie.Id" selected>$leibie.Name</option>
<!--#else-->
#end
</select> 
</p>
<p>新闻内容:<textarea id="Mgs" name="content">$Data.shuju.Content</textarea></p>
<script type="text/javascript">
    var msg = document.getElementById("Mgs");
    CKEDITOR.replace(msg);
</script>
<p><input type="submit" name="tijiao" value="发布" /></p>
</form>
#parse("/Admin/Foot.htm")
搜索更多相关主题的帖子: color 最好 
2014-06-08 11:20
快速回复:调试错误了。谁熟悉 NVelocity 模板引擎,小弟感激不尽。最好是能帮我 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.044728 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved