
By Using AJAX Timer and Update Panel we can develop Updatable News Marquee, Latest rows will add automatically to Marquee, like this sample used in Stock Marquee which view last symbols (live).
UpdatePanel and Timer place inside marquee tag < >.
Background
In the past we can't catch every new row from data source and view it on the marquee without postback.
Using the code
Collapse
public string MarqNews, strTitle;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
NewsTable();
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
strTitle = txtTitle.Text.Trim();
ViewState["Title"] = strTitle;
}
public DataTable NewsTable()
{
DataTable dt_News = new DataTable();
dt_News.Columns.Add("ID", typeof(int));
dt_News.Columns.Add("Title", typeof(string));
dt_News.Rows.Add(1, "CNN");
dt_News.Rows.Add(2, "BBC");
dt_News.Rows.Add(3, "America Radio");
dt_News.Rows.Add(4, "Euro News");
dt_News.Rows.Add(5, "India News");
if (txtTitle.Text != "")
{
dt_News.Rows.Add(dt_News.Rows.Count + 1, (string)ViewState["Title"]);
}
Cache["UpdatedNews"] = dt_News;
return (DataTable)Cache["UpdatedNews"];
}