Oke we Start.
I Make three Textbox and one button.you can see thiss below.!
code on default.ascx.
<style type="text/css">
.tablecoment
{
width: 390px;
font-size: 14px;
font-family: inherit;
background-color: darkcyan;
color: antiquewhite;
}
.tablerepeate
{
background-color: darkGray;
font-size: 19px;
color: aliceBlue;
font-family: -webkit-pictograph;
}
</style>
<table>
<tr>
<td>
EnterName:
</td>
<td>
<asp:TextBox ID="txtName" runat="server" Width="200px" Height="20px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Subject:
</td>
<td>
<asp:TextBox ID="txtsubject" runat="server" Width="200px" Height="20px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
EnterComment:
</td>
<td>
<asp:TextBox ID="Txtcomment" runat="server" TextMode="MultiLine" Width="300px" Height="100px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</td>
</tr>
</table>
<asp:Repeater ID="rptcomentar" runat="server">
<HeaderTemplate>
<table class="tablecoment">
<tr>
<td colspan="2" class="tablerepeate">
<b>Comments</b>
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<table>
<tr>
<td>
Subject:
<asp:Label ID="lblsubject" runat="server" Text='<%#Eval("Subject") %>'></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblcomment" runat="server" Text='<%#Eval("Comment") %>'></asp:Label>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>
Post By:
<asp:Label ID="lbluser" runat="server" Text='<%#Eval("Username") %>'></asp:Label>
</td>
<td>
Created Date:
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("PostedDate") %>'></asp:Label>
</td>
</tr>
</table>
<hr />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
code on default.ascx.cs.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Entities.Modules;
namespace Module.Comentar
{
public partial class _default : PortalModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
baindcomentar();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
FormRegisterSolution.Entitas.Comentar objcomentar = new FormRegisterSolution.Entitas.Comentar();
objcomentar.Username = txtName.Text;
objcomentar.Subject = txtsubject.Text;
objcomentar.Comment = Txtcomment.Text;
objcomentar.PostedDate = DateTime.Now;
FormRegisterSolution.Controler.ControlCommentar objcontrol = new FormRegisterSolution.Controler.ControlCommentar();
objcontrol.addcomentar(objcomentar);
}
catch (Exception ex)
{
}
}
private void baindcomentar()
{
List<FormRegisterSolution.Entitas.Comentar> objcomentarlist = new List<FormRegisterSolution.Entitas.Comentar>();
objcomentarlist = new FormRegisterSolution.Controler.ControlCommentar().comentarlist.OrderByDescending(s => s.Userid).Take(3).ToList();
rptcomentar.DataSource = objcomentarlist;
rptcomentar.DataBind();
}
}
}
and you can see image finaly this below.
---Ok Thank you ,I hope can be useful-----
Tidak ada komentar:
Posting Komentar