Use ajax to achieve typing results ,,,

Source: Internet
Author: User

Create defa9.9.aspx page

Use sriptmanager and updatapanel to put one in updatapanel, implement Timer, and use two viewstates. viewstate ["Index"] stores the content printed by subscript and viewstate ["content ,,,

Code:

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Threading;

Public partial class default6: system. Web. UI. Page
{

Public int index {
Get {return (INT) viewstate ["Index"];}
Set {viewstate ["Index"] = value ;}
}
Public String content
{
Get {return (string) viewstate ["content"];}
Set {viewstate ["content"] = value ;}
}

Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Content = "Hello, I'm your grandfather ,,,,";
Index = 0;
Timer1.enabled = true;
}

}

Protected void timereffectick (Object sender, eventargs E)
{

This. label1.text + = content [Index]. tostring ();
Index ++;
If (index> = content. Length ){

Timer1.enabled = false;
}
}



}

Page:

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default9.aspx. cs" inherits = "default9" %>

<! 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">
<Title> </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: scriptmanager id = "scriptmanager1" runat = "server">
</ASP: scriptmanager>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Asp: timer id = "timer1" runat = "server" interval = "1000" ontick = "timer1_tick">
</ASP: timer>
<Asp: Label id = "label1" runat = "server" text = ""> </ASP: Label>
</Contenttemplate>


</ASP: updatepanel>

</Div>
</Form>
</Body>
</Html>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.