Use HTML to call C # [architecture]

Source: Internet
Author: User

Let's take a look at HTML.Code:

< Html >
< Head >
< Title > Demo for how to call C # business from HTML page </ Title >
< Script SRC = "Http://www.zivosft.com/core/lib.js" > </ Script >
</ Head >
< Body >
< Form ID = "Default" Action = "Zivsoft. Business. demoshow. addsample" >
< Input ID = "" Type = "Text" > +
< Input ID = "B" Type = "Text" > +
< Input ID = "C" Type = "Text" > =
< Input ID = "TXT" Type = 'Text' >
< Input Type = "Button" ID = "Add" Value = "Submit" Onclick = "Callbusiness ();" >
</ Form >
</ Body >
</ Html >

Let's take a look at the HTML interface:

The above is a very simple demo to demonstrate how to construct three input boxes through the HTML interface, and call the descendant C # logic zivsoft. Business. demoshow. addsample to implement the sum of three numbers.

 

Let's take a look at the background C # business logic:

Namespace Zivsoft. Business. demoshow
{
Public   Class Addsample: basecontrol {
Private   Void Add_click (icomponent Com)
{
This . Txt. Value = System. Convert. toint32 ( This . Ga-. value) + System. Convert. toint32 ( This . TBB. value) + System. Convert. toint32 ( This . TBC. value ); } }
}

Finally, let's look at a piece of JavaScript code:

VaR URL =   Http://www.zivsoft.com/cloudserver/default.aspx ;
Req. Open ( " Post " , URL, async );
Req. setRequestHeader ( " Content-Type " , " Application/X-WWW-form-urlencoded; charset = UTF-8 " );
While (Reqdata. indexof ( ' / ' ) ! =   - 1 ) { Reqdata = Reqdata. Replace ( ' / ' , ' % 2f ' ); }
Reqdata = Reqdata. Replace ( / \ < / G, " % 3d " );
Reqdata = Reqdata. Replace ( / \> / G, " % 3E " );
// Send the request data to the cloud aspxProgram
Req. Send (reqdata );
If ( ! Async) {
If (Req. Status =   200 ) {
Return Req. responsetext;
} Else   {
Alert ( ' Cloud server error ' );
}
}

 

I don't need to write much. Do kids know what's going on?

Nowadays, the technology is changing with each passing day, and the terminal program layers are not consistent, such as XAML and HTML5. Although the UI is becoming more and more beautiful, there are more and more application terminals, such as Android and WP7, but what remains unchanged is the backend service. Proficient in C # or Java, join the cloud computing background !!!

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.