Click here to Skip to main content
6,635,160 members and growing! (17,060 online)
Email Password   helpLost your password?
Web Development » Ajax and Atlas » General     Intermediate License: The Code Project Open License (CPOL)

Updatable News Marquee

By Khaled Mohamed Rawy

Up-To-Date News Marquee Without Postback
C#, .NET (.NET 3.0), ASP.NET, Ajax
Posted:15 Mar 2008
Views:10,694
Bookmarked:11 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 1.02 Rating: 1.31 out of 5
4 votes, 66.7%
1
1 vote, 16.7%
2
1 vote, 16.7%
3

4

5

Introduction

A lot of Portals and News Websites add "News Marquee" which shows latest News when visitor request the page, So we need to show up-to-date news without refresh the page, we can do this with using AJAX Timer, UpdatePanel and Html Marquee < > tag.

Background

Html Marquee catch last news when visitor refresh the page. We would like to follow latest News without any postback.

Using the code

            

    //Add More News to the Marquee
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        DataTable dt_NewsNews;
        if (ViewState["GetNews"] != null)
        {
            dt_NewsNews = (DataTable)ViewState["GetNews"];
        }
        else
        {
            dt_NewsNews = NewsTable();
        }

        DataRow dr = dt_NewsNews.NewRow();
        dr["ItemID"] = dt_NewsNews.Rows.Count + 1;
        dr["Title"] = "BBC" + dt_NewsNews.Rows.Count;
        dt_NewsNews.Rows.Add(dr);
        ViewState["GetNews"] = dt_NewsNews;
    }

    //Create Data Source (DisConnected Method: DataTable)
    public DataTable NewsTable()
    {
        DataTable dt_GetNews = new DataTable();
        DataColumn dc;
        dc = new DataColumn("ItemID", System.Type.GetType("System.String"));
        dt_GetNews.Columns.Add(dc);
        dc = new DataColumn("Title", System.Type.GetType("System.String"));
        dt_GetNews.Columns.Add(dc);

        DataRow dr = dt_GetNews.NewRow();
        dr["ItemID"] = "1";
        dr["Title"] = "BBC";
        dt_GetNews.Rows.Add(dr);
        ViewState["GetNews"] = dt_GetNews;

        return ((DataTable)ViewState["GetNews"]);
    }


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Khaled Mohamed Rawy


Member
Khaled Mohamed Rawy
ASP.Net Developer
Egypt Cairo
khaledrawy@hotmail.com
khm@alawael-it.com
Occupation: Web Developer
Location: Egypt Egypt

Other popular Ajax and Atlas articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
General[My vote of 2] ur script not working properly Pinmembershahab ali rizvi2:23 18 Jun '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 15 Mar 2008
Editor:
Copyright 2008 by Khaled Mohamed Rawy
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project