I would like to display real-time message from database on top of main page in my project so that I can view it anytime when I navigate other webpages. I manage to bind the updated message in dataset but the RadTicker is missing from the page. Below is the workaround that I have done in my project.
Currently, I'm using RadAjaxTimer to trigger RadTicker to update the message when there is any new message added into database. I created these 2 controls and script manager in ascx page as global user controls in my project. Then, I'll call these reference controls in a RadAjaxPanel on the main page and bind the updated message in RadTicker on ascx page Page_Load event and RadAjaxTimer_Tick event. I only see AjaxLoadingPanel displays during data binding and the RadTicker is missing from the main page after it is done. What happens to the RadTicker? Does it cause by System.Threading.Thread.Sleep(5000) that I configured in RadAjaxTimer_Tick event? Is it used to control the AjaxLoadingPanel display time?
Below is the ascx page that I created in my project.
<%
@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<%
@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %>
<%
@ Control Language="C#" AutoEventWireup="true" CodeBehind="Ticker.ascx.cs" Inherits="ACE.ACETM.GlobalWebUI.Ticker" %>
<%
@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<
div style="COLOR: crimson; BACKGROUND-COLOR: black">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<telerik:RadTicker id="RadTicker1" runat="server" AutoStart="true" loop="true" AutoAdvance="true" AutoPostBack="true">
</telerik:RadTicker>
<radA:RadAjaxTimer ID="RadAjaxTimer1" runat="server" Interval="10000" OnTick="RadAjaxTimer1_Tick" />
</
div>
public
partial class Ticker : System.Web.UI.UserControl
{
public MessageCenterDS msgCenterDS;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MessageCenterBR BF = new MessageCenterBR();
msgCenterDS = BF.GetTestMessages(
"ABC");
RadTicker1.DataSource = msgCenterDS.MC_MESSAGES;
RadTicker1.DataTextField =
"MC_MESSAGE";
RadTicker1.DataBind();
}
}
protected void RadAjaxTimer1_Tick(object sender, Telerik.WebControls.TickEventArgs e)
{
System.Threading.
Thread.Sleep(5000);
MessageCenterBR BF = new MessageCenterBR();
msgCenterDS = BF.GetTestMessages(
"ABC");
RadTicker1.DataSource = msgCenterDS.MC_MESSAGES;
RadTicker1.DataTextField =
"MC_MESSAGE";
RadTicker1.DataBind();
}
}
Below is the main page that I created in my project.
<%
@ register tagprefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" %>
<%
@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %>
<%
@ Register TagPrefix="uc2" TagName="Ticker" Src="~/common/usercontrols/Ticker.ascx" %>
<
table border="0" cellpadding="0" cellspacing="0" width="100%" style="height:100%" class="tblBackground">
<
tr>
<td colspan="3" align="center">
<div>
<radA:RadAjaxPanel ID="RadAjaxPanel1" Visible="true" runat="server" LoadingPanelID="AjaxLoadingPanel1" EnableAJAX="true">
<uc2:Ticker id="Ticker1" runat="server" OnLoad="Timer1_Load" />
</radA:RadAjaxPanel>
<radA:AjaxLoadingPanel ID="AjaxLoadingPanel1" runat="server" Height="75px" Width="75px">
<img alt="loading..." src="RadControls/AjaxTimer/Skins/Default/loading.gif" />
</radA:AjaxLoadingPanel>
</div>
</td>
</tr>
</
table>
protected
void Timer1_Load(object sender, EventArgs e)
{
}
Please advice if I have done anything wrong in the coding. I need a solution urgently. I appreciate if you may provide a sample project for me. Thank you.
Regards,
Emily.