Tuesday, April 3, 2012

How to make Marquee in ASP.NET web page and dynamically assign the value to it.

 

When you make a web application it is always good to make a colourful user interface.  One of the most attractive feature in HTML is Marquee. Today we will see how to use marquee in ASP.NET web application.

Here we will use label to assign the text which moves inside the marquee tag.

We will see the code now,

<div> 
<marquee direction="right" scrollamount="2" loop="true" width="100%" bgcolor="#ffffff" >
    <asp:Label id="lblMarquee" runat="server" ForeColor="ForestGreen" Font-Bold="True" ></asp:Label>
</marquee>
</div>

Here what we are doing is we kept the label inside marquee tag so label will move based on the marquee settings.

Now if you assign any value from your code behind to this label it will move or rotate based on the marquee settings.

1 comment:

Baiju EP said...

i tried your code with the following vb code it is working but shows only one row data.i want to display emp_no, appointment, name, shop from baiju where remark contains text 'PO TO' .here baiju is the table and emp_no, appointment, name, shop and remark are the fields in baiju

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim con As New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("wkspConnectionString").ConnectionString
con.Open()
Dim qstr As String
qstr = "SELECT * FROM baiju "
Dim msadp As New SqlDataAdapter(qstr, con)
Dim dts As New DataSet
dts.Clear()
msadp.Fill(dts, "baiju")
lblMarquee.Text = dts.Tables("baiju").Rows(0).Item("remarks")


End Sub