SideBarControl
ISideBar
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Digita.Tustena.WebControls; using Digita; public partial class SideBar_MyGadget : SideBarControl, ISideBar { public SideBar_MyGadget() { this.ID = "MyGadget"; this.Title = "La mia Chat Interna"; if (HttpContext.Current.Application["Chat_Box"] == null) { HttpContext.Current.Application.Add("Chat_Box", string.Empty); } } protected void Page_Load(object sender, EventArgs e) { ((AjaxedPage)Page).GetAjaxed(PostMessage, "MessageList", null, AjaxedPage.AjaxedType.PostbackEvent); } protected override void OnInit(EventArgs e) { base.OnInit(e); PostMessage.Click += new EventHandler(PostMessage_Click); } void PostMessage_Click(object sender, EventArgs e) { ((AjaxedPage)Page).RemoveAllAjaxedControl(); ((AjaxedPage)Page).GetAjaxed(MessageList, "MessageList", null, AjaxedPage.AjaxedType.Inner); ((AjaxedPage)Page).GetAjaxed(Message, null, null, AjaxedPage.AjaxedType.Inner); ((AjaxedPage)Page).GetAjaxed(PostMessage, null, null, AjaxedPage.AjaxedType.Inner); if (!string.IsNullOrEmpty(Message.Text)) { string msg = string.Format("<span style=\"color:Red\">{1} scrive:</span>{0}{2}{0}{3}", Environment.NewLine, UC.UserRealName, Message.Text, Application["Chat_Box"]); Message.Text = string.Empty; if (msg.Length > 1000) { msg=msg.Substring(0, msg.LastIndexOf("<span ")); } Application["Chat_Box"] = msg; } } protected override void OnPreRender(EventArgs e) { MessageList.Text = Application["Chat_Box"].ToString().Replace(Environment.NewLine, "<br/>"); base.OnPreRender(e); } protected override void Render(HtmlTextWriter writer) { base.Render(writer); } }
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyGadget.ascx.cs" Inherits="SideBar_MyGadget" %> <twc:jscontrolid runat="server" Identifier="Chat"></twc:jscontrolid> <div style=" color:Black; padding:2px; margin:2px; width:100%; height:100px; overflow-y: scroll; background-color:White; margin:2px;" id="MessageList"> <asp:Literal ID="MessageList" runat="server"></asp:Literal> </div> <div> <asp:TextBox runat="server" ID="Message" CssClass="BoxDesign"></asp:TextBox> </div> <div class="Tbutton" style="text-align:right"> <twc:LocTustenaButton runat="server" ID="PostMessage" Logo="plus" Text="Invia"></twc:LocTustenaButton> </div> <script type="text/javascript"> function poolChat() { eval($('#' + jsControlIdChat + 'PostMessage').attr('href')); chatTimeout = setTimeout('poolChat()', 5000); } AJAXED.scrollToInjection = false; var chatTimeout=setTimeout('poolChat()', 5000); </script>