简体   繁体   中英

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>
  1. Create UpdatePanel.
  2. Create a Label inside UpdatePanel.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM