您的位置:首页 > 数据库

字符串转化为日期字段并存入数据库

2010-12-11 20:33 218 查看
前台代码:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <mce:script src="../script/jquery-1.4.3.js" mce_src="script/jquery-1.4.3.js" type="text/javascript"></mce:script>
    <mce:script type="text/javascript"><!--
        $(function () {
            $("#insert").click(function () {
               
                $.ajax({
                    type: "GET",
                    url: "insertDate.ashx",
                    data: { date: $("#date").val() },
                    success: function (date, textStatus) {
                        alert(date);
                    }

                });
            });
            $("#loading").ajaxStart(function () {
                $(this).show();
            });
            $("#loading").ajaxStop(function () {
                $(this).hide();
            });
        })
    
    
    
// --></mce:script>
</head>
<body>
<input type="text" id="date" />
<input type="button" id="insert"  value="插入"/>
<div id="loading" style="display:none" mce_style="display:none" >加载中……</div>
</body>
</html>






后台代码:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Maticsoft.Model;
using Maticsoft.BLL;
namespace Maticsoft.Web.insertDate
{
    /// <summary>
    /// insertDate 的摘要说明
    /// </summary>
    public class insertDate : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
           DateTime s=Convert.ToDateTime(context.Request["date"] )  ;
          Maticsoft.Model.demo demo1 = new Model.demo();
           Maticsoft.BLL.demo update1 = new BLL.demo();
           demo1.date= s;
           demo1.name = "wtq";
           demo1.classid = 4;
           demo1.id = 58;
           demo1.parentid = 5;
           update1.Update(demo1);
            

            context.Response.Write(s.ToString());
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}










采用三层价格。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: