-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDefault.aspx.cs
More file actions
46 lines (39 loc) · 1.55 KB
/
Default.aspx.cs
File metadata and controls
46 lines (39 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Threading;
using DevExpress.Web;
public partial class _Default : System.Web.UI.Page {
protected void CallbackPanel_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
ASPxCallbackPanel panel = (ASPxCallbackPanel)sender;
NoCommentsLabel.Visible = false;
Thread.Sleep(3000);
ASPxLabel comment = new ASPxLabel() {
Text = string.Format("[{0}]\n{1}\n\n",
DateTime.Now.ToLocalTime(),
!string.IsNullOrEmpty(TextBox.Text) ? TextBox.Text : "Empty comment"
),
CssClass = "comment"
};
List<ASPxLabel> comments = (List<ASPxLabel>)Session["comments"] ?? new List<ASPxLabel>();
comments.Add(comment);
panel.Controls.Add(comment);
Session["comments"] = comments;
CountLabel.Text = "Comments Count : " + comments.Count;
}
protected void CallbackPanel_Init(object sender, EventArgs e) {
if(!IsPostBack && !IsCallback)
Session.Clear();
RecreateComments(sender);
}
private void RecreateComments(object sender) {
List<ASPxLabel> comments;
if((comments = (List<ASPxLabel>)Session["comments"]) != null) {
CountLabel.Text = "Comments Count : " + comments.Count;
ASPxCallbackPanel panel = (ASPxCallbackPanel)sender;
NoCommentsLabel.Visible = false;
foreach(ASPxLabel comment in comments) {
panel.Controls.Add(comment);
}
}
}
}