Sreeranga Vinjamuri Sreeranga Vinjamuri - 2 months ago 10
ASP.NET (C#) Question

How to Display A Text / Message in Web Page Using ASP.NET

In My web page In a portion i want to display a text/message and that text/message has to change after 15 seconds and it has to replaced with another text/message in the same portion. I Created this web application using ASP.NET.

In above Image I want to Display the Text/Message. How can i do ?

ASPX :

<table>
<tr>
<td style="width: 150px">
<a href="http://www.wissen.com">

<img alt="" class="style4" src="Wissen_logo.png" />
</a>
</td>

<td style="width: 1000px; background-color:Aqua">
<marquee behavior="scroll" scrollamount="3" direction="left" width="1000">ghdkj * hchjsdgfhgflghl * yuftwefrweirgeweko</marquee>
</td>
</tr>
</table>

Answer

JS

 <script type="text/javascript">
    var i=1;
    var stat1="foo";
    var stat2="Bar";
    var stat3="foofoo";

    function showText(){
        var msgNo="stat"+i;
        msgNo=eval(msgNo);
        var tgtLabel=document.getElementById("spnRandom");
        tgtLabel.innerHTML=msgNo;
        i=i+1;
        if(i==4){
        i=1;
        }
    }

    window.onload=function(){
                    window.setInterval(showText,1000);
                };
    </script>

HTML

<table>
    <tr>
        <td style="width: 150px">
    <a href="http://www.wissen.com">

            <img alt="" class="style4" src="Wissen_logo.png" />
    </a>
    </td>

    <td style="width: 1000px; background-color:Aqua">
    <div>
<span id="spnRandom"></span>
</div>
    </td>
    </tr>
    </table>

Here is a working Fiddle

If you want it for 15 second, just change the value from 1000 to 15000