Looking back at ext, I have been engaged in. Net rapid development (I don't like Java's messy jar packages, and the version control capability is too poor ). Although ext is a pure UI, it seems to have a close relationship with Java. Among all the examples of forming points found, ext is mostly related to Java, webService and ASP are not applicable, and ext is very convenient in Interface Design. However, in communication, only the middleware such as JSON or XML can be used for transmission, resulting in interpretation and transmission costs, webService requires a lot of security effort, and the efficiency is also very low. In addition, the latency of using a LINQ image is used. net to do ext is really painful, and there is no big difference with the refresh mechanism eliminated by Aspx. Today, I am here to free everyone.
I like ext and finally think of a perfect integration.
1. Vs2008 supports JS single-step debugging and supports breakpoint debugging of JS (No needCodeTIPS: you can improve your proficiency. Check if you want to add the JS file with code prompts in vs2008)
2. The master node defines all JS calls.
<% @ Master language = "C #" autoeventwireup = "true" codefile = "ext2empty. master. cs" inherits = "tmksoft. Web. ext2empty" %>
<HTML>
<Head runat = "server">
<Title> tmksoft CRM V2.0 </title>
<SCRIPT type = "text/JavaScript">
VaR baseurl = "<% = baseurl %> ";
</SCRIPT>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<LINK rel = "stylesheet" type = "text/CSS" href = "../JavaScript/EXT/resources/CSS/ext-all.css"/>
<SCRIPT type = "text/JavaScript" src = "<% = baseurl %> JavaScript/EXT/adapter/EXT/ext-base.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "<% = baseurl %> JavaScript/EXT/ext-all.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "<% = baseurl %> JavaScript/EXT/build/locale/ext-lang-zh_CN.js"> </SCRIPT>
<% -- <SCRIPT type = "text/JavaScript">
Ext. util. CSS. swapstylesheet ("theme", "<% = baseurl %> app_themes/slate/CSS/skin.css ");
</SCRIPT> -- %>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: contentplaceholder id = "contentmainworkspace" runat = "server">
</ASP: contentplaceholder>
</Div>
</Form>
</Body>
</Html>
3. All Web pages inherit the master, and the background class can directly write the C # method, just like how to write.
The following code replaces Ajax communication:
[Ajax. ajaxmethod (httpsessionstaterequirement. readwrite)]
Public bool usercheck (string name, string pass)
{
If (name. Equals ("AA") & pass. Equals ("AA "))
{
Return true;
Session ["uname"] = Name;
Session ["upass"] = pass;
}
Else
{
Return false;
}
}
4. Front-end JS-AJAX direct call server Method
// Now you only need to call the class. method directly. The efficiency test is very good, and the page is refreshing. What you see is what you get. It's so nice !!
VaR login = function (){
VaR c = login. usercheck (document. getelementbyid ('uname'). Value, document. getelementbyid ('upass '). value );
If (C. Value = true)
{
Alert ('pass ');
}
Else {
Alert ('disallow ');
}
VaR ck = login. sessioncheck ();
If (CK. Value) {alert ('logged in ')} else {alert ('not logged in ');}
// The original ext implementation is very troublesome. You need to follow the steps below
//// Execute the submit of the current form panel
// F. Form. Submit ({
//// Text information displayed when an action occurs
// Waitmsg: 'login ......',
/// Address pointed to when submit occurs
// URL: 'http: // localhost: 2020/service1.asmx/userlogin ',
/// Form submission method
// Method: 'post ',
//// Action that occurs when data verification is passed
// Success: function (Form, Action ){
// Window. Location. href = 'index.htm ';
//},
/// Otherwise ......
// Failure: function (Form, Action ){
// Reset ();
// If (action. failuretype = ext. Form. Action. server_invalid)
// Ext. MessageBox. Alert ('Warning ', action. Result. errors. msg );
//}
//});
EXT perfect integration is finally completed. It takes only 3 minutes for you to quickly draw the interface with xtype (because of code prompts and single-step debugging ), it takes only three minutes for you to quickly complete the code for adding, deleting, querying, and modifying databases (because Microsoft C # has done too much for us ), you only need 3 minutes to connect the front and back-end (that is, the independent UI-JS interface, but also an independent business logic layer), there is 1 minute we went out to tease the next Company's little sister.
http://hi.baidu.com/tmk_xj/blog/item/f73e1a101c1883f9c3ce79a1.html