利用Ajax技术写一个迷你留言板WEB控件

作者:凯旋网络来源:凯旋网络
h:1px;
border-right-width:1px;
border-color:#BBBBBB;
}
.Gbody
{
width:200px;
border-style:solid;
border-top-width:0px;
border-bottom-width:0px;
border-left-width:1px;
border-right-width:1px;
border-color:#BBBBBB;
padding:3px 5px 3px 5px;
}
.Gend
{
width:200px;
border-style:solid;
border-top-width:0px;
border-bottom-width:1px;
border-left-width:1px;
border-right-width:1px;
border-color:#BBBBBB;
padding:3px 5px 3px 5px;
}
.Gname
{
width:190px;
 font-size:12px;
 color:blue;
}
.Gcontent
{
width:190px;
word-break:break-all;
color:#444444;
font-size:12px;
padding: 3px 0 3px 0;
border-style:dotted;
border-top-width:0px;
border-bottom-width:1px;
border-left-width:0px;
border-right-width:0px;
border-color:#BBBBBB;
}
</style>

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="Gtitle"><asp:Label ID="Label1" runat="server" Text="留言板"></asp:Label></div>
        <div class="Gbody"><asp:DataList ID="DataList1" runat="server" >
        <ItemTemplate>
        <div class="Gname"><%# DataBinder.Eval(Container.DataItem, "name") %> 说:</div><div class="Gcontent"><%# DataBinder.Eval(Container.DataItem, "content") %></div>
        </ItemTemplate>
        </asp:DataList></div>
        <div class="Gend"><asp:TextBox ID="TextBox1" runat="server" Width="150px" />
        <asp:Button ID="Button1" runat="server" Text="留言" OnClick="Button1_Click" /></div>
    </ContentTemplate>
</asp:UpdatePanel>


这样就可以完成这个控件了,然后就是在页面上调用这个控件了,调用这个控件的页面必须有一个ScriptManager控件才能使用。

此控件修改一下可以做为文章评论控件用,加上个:更多。。。,按文章ID显示评论就可以用了。

初学Ajax,做一应用,做为学习日志。还望多指教。
http://www.cnblogs.com/aowind/archive/2006/11/21/567157.html

  • 广告推荐