Mootools framework [1]-element: Advanced Application Example

Source: Internet
Author: User

Note: More comprehensive instances of the element class will be supplemented later.

Front-end:

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

<! 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> mootools [1] -- advanced application example of element </title>
<SCRIPT type = "text/JavaScript" Language = "JavaScript" src = "mootools-1.2-core-jm.js"> </SCRIPT>

<SCRIPT type = "text/JavaScript">

// Add an operation event to the page-domready.
Window. addevent ("domready", function (){

// Add a click event for btnsent.
$ ('Btnsent'). addevent ('click', function (){
If ($ ('txtcontent'). innertext = ''){
Alert ('the sent content cannot be blank! ');
Return;
}

// Ult2.aspx creates a page. In fact, it stores data temporarily and extracts and displays the data in MessageBox.
VaR url = 'default2. aspx ';
VaR postdata = $ ("postmessage"). toquerystring ();
New Ajax (URL, {method: 'post', oncomplete: function (){

$ ('Messagebox'). innerhtml + = This. response. text;
// The innerhtml method can be replaced by sethtml, because innerhtml is used in Dom operations, and sethtml is newly defined in the mootools framework.
}
}). Request (postdata );
});

});
</SCRIPT>
</Head>
<Body>
<Div style = "margin: auto; text-align: center;">
<Div style = "width: pixel PX; Height: 700px;">
<Div id = "MessageBox"> </div>
<HR/>
<Form ID = "postmessage" method = "Post" name = "postmessage" runat = "server">
<Div>
<Ul>
<Li style = "list-style-type: none;"> enter your network name: & nbsp; <input id = "txtname" runat = "server" value = "Enter the network name"/>
</LI>
</Ul>
<Ul>
<Li style = "list-style-type: none;"> enter the content to be sent: <textarea id = "txtcontent" runat = "server" Cols = "20" rows = "4"> </textarea> </LI>
</Ul>
<Ul>
<Li style = "list-style-type: none; "> <input type =" button "id =" btnsent "runat =" server "value =" send "onserverclick =" btnsent_serverclick "/> </LI>
</Ul>
</Div>
</Form>
</Div>
</Div>
</Body>
</Html>

Background:

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class _ default: system. web. UI. page
{< br> protected void page_load (Object sender, eventargs e)
{< br> If (ispostback)
{< br> If (! String. isnullorempty (txtname. Value )&&! String. isnullorempty (txtcontent. value. Trim ()
{

String name = txtname. value. Trim ();
String content = txtcontent. value. Trim ();
String MSG = "<div> <ul> <li>" + name + ":" + content + "</LI> </ul> </div> ";

Response. Clear ();
Response. Write (MSG );
Response. End ();
}
Else if (! String. isnullorempty (txtcontent. value. Trim () & string. isnullorempty (txtname. Value ))
{
String name = "Tourist ";
String content = txtcontent. value. Trim ();
String MSG = "<div> <ul> <li>" + name + ":" + content + "</LI> </ul> </div> ";
Response. Clear ();
Response. Write (MSG );
Response. End ();
}
}

}

}

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.