题图
![]()
d
3.
use master go -- ============================================= -- ylb:仿腾讯微博/记事本 -- developmentTime:11:47 2012-04-24 -- linkUrl:http://t.qq.com/messages/note.php -- ============================================= IF EXISTS (SELECT * FROM master..sysdatabases WHERE name = N'TQQMessage') DROP DATABASE TQQMessage GO CREATE DATABASE TQQMessage GO use TQQMessage go -- ============================================= -- ylb1,Note -- remark:记事本 -- ============================================= create table Note ( noteId int primary key identity(100,1), --编号[PK] content varchar(140), --内容 pubdate datetime default(getdate()), --发布时间[DF] userId int --用户编号[FK] ) go select *from Note -- ============================================= -- ylbTestData -- ============================================= go --1,发表一条 insert into Note(content,userId) values('哦 知道别人在拒绝,只是你知道我是怎么样想的吗?不知道了。所以你才这样做。.',100) go --2,统计发表的数量,根据userId select count(*) from Note where userId=100 go --3,查询记事本列表,根据userId select noteId,content,pubdate from Note where userId=100 order by noteId desc go --4,修改一条记事,根据noteId update Note set content='newContent' where noteId=100 go --5,删除记事,根据noteId delete Note where noteId=100
4.1,前台 4.1.1
4.1.2
5.1,前台 /Note.aspx
5.1,前台 /Note.aspx ![]() ![]() <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Note.aspx.cs" Inherits="Note" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www./TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www./1999/xhtml"> <head runat="server"> <title></title> <link type="text/css" href="css/style_120419.css" /> <style type="text/css"> .mainmain{ margin:auto;} .main{ width:400px; background-color:White; margin:auto; margin-top:30px; margin-bottom:30px} .left{ float:right;} </style> <script type="text/javascript" src="js/jquery-1.4.1.js"></script> <script type="text/javascript"> //发送记事本 var sendNote = function () { var data = { type: 'add', content: $("#content").val() } $.post("DataMessage.aspx", data); //清空文本框 $("#content").val(""); } //2,删除一条信息 var deleteNote = function (noteId) { var data = { type: "delete", noteId: noteId } $.post("DataMessage.aspx", data); } //3,修改一条信息 var updateNote = function (noteId, content) { var data = { type: 'update', noteId: noteId, content: content } $.post("DataMessage.aspx", data); } </script> </head> <body class="mainmain"> <div class="main"> <hr /> <h3>记事本</h3> <hr /> <div id="noteBox"> <div> <textarea id="content" name="content" rows="3" style="width: 396px"></textarea> </div> <div style="padding-right:20px; padding-left:20px;"> <span class="left">  <input id="btnSendNote" type="button" value="发送" onclick="sendNote()" /></span> <span class="left">还能输入<em>140</em>字</span> </div> </div> <hr /> <div> <h3>共有<span class="noteNum">0</span>条记事</h3> </div> <hr /> <asp:Panel ID="pnlEmpty" runat="server"> <div style=" margin:30px;"> <strong>这里是微博宁静的一角,只留给自己</strong> </div> </asp:Panel> <asp:Panel ID="pnlFull" runat="server"> <div class="listWrapper"> <asp:Repeater ID="rptList" runat="server"> <ItemTemplate> <div class="msgBox"> <div class="msgCnt"> 蓝蓝的天,暖暖的阳光洒满大地。在树荫的一角坐着一个少年。看着翠绿的草、树枝,感受着生命的美好,思索着未来,对未来充满憧憬。</div> <div class="pubTime"> <span class="time">1分钟前</span></div> <p class="btnBox"> <a class="replyMsg btn" href="http://t.qq.com/messages/note.php#">修改</a> <a class="btn delBtn" onclick='deleteNote(<%#Eval("noteId") %>)' href="javascript:void(0)">删除</a></p> </div> </ItemTemplate> </asp:Repeater> </div> </asp:Panel> </div> </body> </html>
/DataMessage.aspx 信息处理页面 ![]() ![]() using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class DataMessage : System.Web.UI.Page { #region 记事本,异步操作方法 /// <summary> /// 1,Add /// </summary> /// <param name="userId"></param> private void Add(int userId) { string content = Request["content"]; //Call Fun NoteOper.Add(content, userId); } /// <summary> /// 2,Delete /// </summary> private void Delete() { int noteId = Convert.ToInt32(Request["noteId"]); //Call Fun NoteOper.Delete(noteId); } /// <summary> /// 3,Update /// </summary> private void Update() { int noteId = Convert.ToInt32(Request["noteId"]); string content = Request["content"]; //Call Fun NoteOper.Update(noteId, content); } #endregion protected void Page_Load(object sender, EventArgs e) { //布局全局变量 int userId = 101; string type = Request["type"]; //根据不同类别,调用不同方法 switch (type) { case "add": Add(userId); break; case "delete": Delete(); break; case "update": Update(); break; } Response.End(); } } 5.2,后台 无
博客园讲解: http://ylbtech.cnblogs.com/ 百度文库开发文档: http://passport.baidu.com/?business&aid=6&un=ylbtech#7 谷歌开源代码下载: http://code.google.com/p/ylbtechopensource/downloads/list
请单击“TQQMessage”
|
|
来自: 昵称10504424 > 《Asp.Net》