Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Notification / Twitter integration



  • Click on the button to get the latest tweets found for asp.net, ajax or software keywords in real time from Twitter.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
        <style type="text/css">
            .wrapper
            {
                width: 390px;
                overflow: hidden;
            }
            
            .profilePic
            {
                margin: 10px 0 0 20px;
            }
            
            .text, .prevSlide, .nextSlide
            {
                display: inline-block;
                zoom: 1;
                *display: inline;
            }

            .text
            {
                width: 290px;
                padding: 10px 0 0 20px;
                vertical-align: top;
            }
            
            .date
            {
                color: #999;
                margin-left: 87px;
                width: 290px;
                background: url(Img/birdy.png) left 11px no-repeat;
                padding: 10px 0 0 23px;
            }
            
            .navigation
            {
                float: right;
                width: 30px;
                padding-bottom: 5px;
            }
            
            .prevSlide, .nextSlide
            {
                width: 11px;
                height: 13px;
                background-image: url(Img/rotatorControls.png);
                background-repeat: no-repeat;
            }
            
            *html .prevSlide, *html .nextSlide
            {
                background-image: url(Img/rotatorControlsIE6.gif);
            }
            
            .prevSlide
            {
                margin-right: 4px;
                background-position: 0 0;
            }
            
            .prevSlide:hover
            {
                background-position: 0 -13px;
            }
            
            .nextSlide
            {
                background-position: -13px 0;
            }
            
            .nextSlide:hover
            {
                background-position: -13px -13px;
            }
        </style>
    </head>
    <body class="BODY">
        <form id="form1" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" ShowSkinChooser="false" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadCodeBlock ID="block" runat="server">
            <script type="text/javascript">
                       //<![CDATA[

                var $ = $telerik.$;


                function GetTweetes(keywords, numPosts, fnk) {

                    var url = "http://search.twitter.com/search.json?q=" + keywords + "&rpp=" + numPosts + "&callback=?";

                    $.getJSON(url, function (data) {
                        if ($.isFunction(fnk)) {
                            fnk.call(this, data.results);
                        }
                    });
                }


                function OnClientShowing(sender, args) {

                    GetTweetes("asp.net&ajax&software", 10, function (data) {
                        var rotator = $find("<%= tweetsRotator.ClientID %>");
                        var currentItems = rotator.get_items();

                        //scroll the rotator to the first item
                        rotator.set_currentItemIndex(0);

                        $(data).each(function (i, post) {
                            //if there is such an item created already - simply replace the content with the latest one
                            var dataItem = data[i];


                            var htmlString = "<div class='wrapper'>" + "<img class='profilePic' src='" + dataItem.profile_image_url + "'></img>" + "<div class='text'>" + dataItem.text + "</div><div class='date'><span class='author'>" + dataItem.from_user + "&nbsp;|&nbsp;</span>" + dataItem.created_at + "</div></div>";

                            if (currentItems[i]) {
                                currentItems[i].get_element().innerHTML = htmlString;
                            }
                            else {
                                //create and add a new item in case there is no such in the rotator - e.g in this demo this will be needed only on first show but in more complex scenario, when the returned by twitter records have different length
                                var radRotatorItemData = {};
                                radRotatorItemData.Html = htmlString;
                                rotator.addRotatorItem(radRotatorItemData, i);
                            }
                        });
                    });
                }

                function ShowNotification() {
                    var notification = $find("<%= RadNotification1.ClientID %>");
                    notification.show();
                }

                          //]]>
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadButton ID="btn" runat="server" Text="Get latest tweets!" Skin="Office2010Black"
            OnClientClicking="ShowNotification" AutoPostBack="false" />
        <telerik:RadNotification ID="RadNotification1" runat="server" Width="400" Animation="Fade"
            EnableRoundedCorners="true" Position="Center" EnableShadow="true" TitleIcon="Img/twitterIcon.png"
            Skin="Office2010Black" AutoCloseDelay="5000" Style="z-index: 35000" LoadContentOn="PageLoad"
            Title="Search: asp.net OR ajax OR software" OnClientShowing="OnClientShowing">
            <ContentTemplate>
                <telerik:RadRotator ID="tweetsRotator" runat="server" RotatorType="Buttons" Height="100"
                    Width="390px" Skin="Office2010Black" ItemWidth="390px">
                    <ControlButtons LeftButtonID="prevButton" RightButtonID="nextButton" />
                </telerik:RadRotator>
                <div class="navigation">
                    <a href="" id="prevButton" title="Previous Slide" class="prevSlide"></a><a href=""
                        id="nextButton" title="Next Slide" class="nextSlide"></a>
                </div>
            </ContentTemplate>
        </telerik:RadNotification>
        <br />
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451