ASP.Net 2.0+AJAX零代码构建简易留言簿

7 篇文章 0 订阅
7 篇文章 0 订阅

零代码,即没有后端代码, 所有东西均通过设计视图拖放完成,下面就是一个使用设计视图完成的留言簿

数据库表 GuestBook:

IDintPK,自增
Namevarchar(50) 
Emailvarchar(50) 
Messagevarchar(50) 
PostDatedatetimegetdate()

通过设计器产生的代码 lishewen.aspx:

< %@ Page  Language ="VB"  AutoEventWireup ="false"  CodeFile ="lishewen.aspx.vb"  Inherits ="Myweb_lishewen"  % >

<! 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  runat ="server" >
    
< title > Untitled Page </ title >

    
< script  type ="text/javascript" >
    
      function pageLoad() {
      }
    
    
</ script >

</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< div >
        
< asp:ScriptManager  ID ="ScriptManager1"  runat ="server"   />
        
< h1 >
            Message List
</ h1 >
        
< br  />
        
< asp:UpdatePanel  ID ="UpdatePanel1"  runat ="server" >
            
< ContentTemplate >
                
< asp:GridView  ID ="messageList"  runat ="server"  AllowPaging ="True"  AutoGenerateColumns ="False"
                    DataKeyNames
="ID"  DataSourceID ="SqlDataSource1" >
                    
< Columns >
                        
< asp:BoundField  DataField ="Name"  HeaderText ="Name"  SortExpression ="Name" ></ asp:BoundField >
                        
< asp:BoundField  DataField ="Email"  HeaderText ="Email"  SortExpression ="Email" ></ asp:BoundField >
                        
< asp:BoundField  DataField ="Message"  HeaderText ="Message"  SortExpression ="Message" ></ asp:BoundField >
                        
< asp:BoundField  DataField ="PostDate"  HeaderText ="PostDate"  SortExpression ="PostDate" >
                        
</ asp:BoundField >
                    
</ Columns >
                
</ asp:GridView >
            
</ ContentTemplate >
        
</ asp:UpdatePanel >
    
</ div >
    
< asp:SqlDataSource  ID ="SqlDataSource1"  runat ="server"  ConnectionString ="<%$ ConnectionStrings:DatabaseConnectionString %>"
        DeleteCommand
="DELETE FROM [GuestBook] WHERE [ID] = @ID"  InsertCommand ="INSERT INTO [GuestBook] ([Name], [Email], [Message], [PostDate]) VALUES (@Name, @Email, @Message, getdate())"
        SelectCommand
="SELECT * FROM [GuestBook]"  UpdateCommand ="UPDATE [GuestBook] SET [Name] = @Name, [Email] = @Email, [Message] = @Message, [PostDate] = getdate() WHERE [ID] = @ID" >
        
< DeleteParameters >
            
< asp:Parameter  Name ="ID"  Type ="Int32"   />
        
</ DeleteParameters >
        
< UpdateParameters >
            
< asp:Parameter  Name ="Name"  Type ="String"   />
            
< asp:Parameter  Name ="Email"  Type ="String"   />
            
< asp:Parameter  Name ="Message"  Type ="String"   />
            
< asp:Parameter  Name ="PostDate"  Type ="DateTime"   />
            
< asp:Parameter  Name ="ID"  Type ="Int32"   />
        
</ UpdateParameters >
        
< InsertParameters >
            
< asp:Parameter  Name ="Name"  Type ="String"   />
            
< asp:Parameter  Name ="Email"  Type ="String"   />
            
< asp:Parameter  Name ="Message"  Type ="String"   />
            
< asp:Parameter  Name ="PostDate"  Type ="DateTime"   />
        
</ InsertParameters >
    
</ asp:SqlDataSource >
    
< br  />
    
< h1 >
        Insert a Message
</ h1 >
    
< br  />
    
< asp:UpdatePanel  ID ="UpdatePanel2"  runat ="server"  UpdateMode ="Conditional" >
        
< ContentTemplate >
            
< asp:DetailsView  ID ="addingForm"  runat ="server"  AutoGenerateRows ="False"  DataKeyNames ="ID"
                DataSourceID
="SqlDataSource1"  Height ="50px"  Width ="125px"  DefaultMode ="Insert" >
                
< Fields >
                    
< asp:BoundField  DataField ="Name"  HeaderText ="Name"  SortExpression ="Name" ></ asp:BoundField >
                    
< asp:BoundField  DataField ="Email"  HeaderText ="Email"  SortExpression ="Email" ></ asp:BoundField >
                    
< asp:BoundField  DataField ="Message"  HeaderText ="Message"  SortExpression ="Message" ></ asp:BoundField >
                    
< asp:CommandField  ShowInsertButton ="True" ></ asp:CommandField >
                
</ Fields >
            
</ asp:DetailsView >
        
</ ContentTemplate >
    
</ asp:UpdatePanel >
    
< asp:UpdateProgress  ID ="UpdateProgress1"  runat ="server" >
        
< ProgressTemplate >
            
< div  style ="position: absolute; top: 2px; left: 0px; width: 103%; text-align: right" >
                
< span  style ="background-color: rgb(204,68,68)" > Loading... </ span ></ div >
        
</ ProgressTemplate >
    
</ asp:UpdateProgress >
    
</ form >
</ body >
</ html >
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值