Silk Webware Home Our Products Contact Us Development Services
MARQUEE WEBCONTROL
Details
VB.Net Examples
C# Examples
Toolbox Setup
Download Control
Purchase Control
Online Demo


Recent Award 
Download all of our Webcontrols

Download all of our Webcontrols. Fully functional trial versions. Includes simple setup instructions and demo code.


 



Smartphone Software 

© SilkWebware 2013 




  Simple Scrolling Message
  Drag and drop a Silk Webware Marquee Webcontrol from your toolbox onto a new or existing webform. (If you do not have a Marquee Webcontrol in your toolbox please see Setup) To set the marquee message right click on the control and select properties. Change the message property to your desired message. That's it, Marquee is ready to scroll a message to the left. For a list of marquee specific properties and descriptions please see Properties. In the example below we change set the message, scroll direction and backcolor in code. As expected these properties can be set at runtime (using code) or designtime (using the webform designer and properties window). Notice in this example we use the bold tag, the Message property will take plain text or html.
 

 

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        'set the message .. notice the use of html tags.

        Marquee1.Message = "Message set at <b>runtime<b>"

        'change the scroll direction using Marquee Direction

        Marquee1.Direction = SilkWebware.Marquee.Direction.Down

        'change the backcolor to Red

        Marquee1.BackColor = Color.Red

 

End Sub


  Databound Marquee (How to Create MarqueeDataItems)
  The true power of the Silk Webware Marquee control comes from it's databinding abilities. In the following example we will create a simple stock ticker. Although the data in this example is from a static xml file, it would not be hard to adapt it to use data from one of the many stock market quote, news and weather webservices available. The first thing we new to do is create an XML file that will contain our dummy data. Add a new XML file to your project and place it in the same folder as the page that will contain the ticker. Name this file StockQuotes.xml. This file should contain the following two quotes with company, symbol and price fields. We will use this as our datasource. (you can also use a DataSet, DataTable, XmlElement and most collections of type IListSource or IEnumerable)

 

<?xmlversion="1.0"encoding="utf-8"?>

<stockquotes>

       < stockquote >

              <company>Silk Webware</company>

              <symbol>SILK</symbol>

              <price>9.99</price>

       </ stockquote >

       < stockquote >

              <company>Your Co</company>

              <symbol>YRCO</symbol>

              <price>77.50</price>

       </ stockquote >

</stockquotes>

In our example we want the marquee message to read
'Current quote for Silk Webware is 9.99 Current quote for Your Company is 77.50'

Drag and drop a Silk Webware Marquee Webcontrol onto your webform. At this stage you may wish to add styling but for this example I will use all of the default settings. Right click the control and click properties. Now click the button next to the MarqueeDataItems Collection. We want to add 3 items here, so click the add button 3 times.
Click the first item and look towards the properties pane. Type next to the Text property "Current Quote for". Click the second Item and type 'company' next to the DataTextField . Click on the third and final Item in the left hand list. The first thing you need to do is set the MarqueeItemType to Hyperlink. A number of new properties will appear. Enter 'price' into the DataTextField and 'symbol' into the HyperlinkField. This will extract the price and symbol data respectively. Finally set the items HyperlinkFormatString by typing the following http://stockserver/details.aspx?s={0} In the real-world this would be a 'more details' page for the quote. After you have finished click OK to save your changes.


If you switch to HTML View you will notice that these MarqueeItems tags have been added to the Marquee control.

<cc1:marquee id="Marquee1" runat="server" Message="A New Message to Scroll">

<cc1:MarqueeItem Text="Current Quote for" MarqueeItemType="TextItem"></cc1:MarqueeItem>

<cc1:MarqueeItem MarqueeItemType="TextItem" DataTextField="company"></cc1:MarqueeItem>

<cc1:MarqueeItem MarqueeItemType="Hyperlink" HyperlinkField="symbol" DataTextField="price" HyperlinkFormatString="http://stockserver/details.aspx?s={0}">

</cc1:MarqueeItem>

</cc1:marquee>



Setting the Marquee DataSource The last thing we need to do is set the DataSource property. We will do this within the Webforms page_load method. The following code shows how to read the XML file and get the appropriate XMLElement (stockquotes) that we will use as our datasource. Once you have done this you are ready to run the example. The results will be a scrolling stock ticker.
 
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase .Load
   Dim xmlDoc As New System.Xml.XmlDocument()
   'get the current path of the xml document
   Dim strXmlFile As String = Server.MapPath("StockQuotes.xml")
   'load a xmlDoc object
   xmlDoc.Load(strXmlFile)
   'get the "stockquotes" XmlElement to bind to the Marquees Datasource.
   Marquee1.DataSource = xmlDoc("stockquotes")
  'databind the control
   Marquee1.DataBind()
End Sub