Processing of special characters of magicajax.net2.0 frame

Source: Internet
Author: User
Tags html tags regular expression string
Ajax found that so many people were using this magicajax framework, but no one found that the framework for special character HTML tags was not processed. The callback displays problems with special characters in the page, such as special symbols &#?; which? On behalf of ISO 8859-1 code) < < > > & & "" And so on, when a box value of <100 boar, which has a less than (<), and the & symbol was translated (& amp), the last text box value Will be turned into & amp LT, with such a few characters. There are two kinds of solutions:
Solution One: When displaying data in a page, all the special symbols are replaced with full-width, but this method is too stupid and too troublesome. The second method is recommended.
For example:
String str = "All pigs at <100 Hall";
Str. Replace (' < ', ', ');//replaced with full corner, however, there are < < > > & these Symbols Oh, a replacement is,
Solution Two: Change Magicajax source code, do not fear, ^-^, this change is not difficult, first to the official website download. net2.0 source code down, open the project, find a class for AjaxCallHelper.cs, this kind of function is really strong AH. Found in the Inside method for encodestring (String str), the source code is as follows:
public static string encodestring (String str)
{
Todo:use 1 Regular expression (faster)
System.Text.StringBuilder sb = new System.Text.StringBuilder (str);
Sb. Replace ("\", "\\\\");
Sb. Replace ("\" "," "\\\");
Sb. Replace ("\ r", "\ R");
Sb. Replace ("\ n", "\\n");
Sb. Replace ("T", "\\t");
Sb. Replace ("<", "<");
Sb. Replace ("&", "&");
Sb. Insert (0, ' \ ");
Sb. Append (' \ ");
Return SB. ToString ();
}
The special characters in the display when the replacement is not OK, the last release project, the problem solved. Oh, too!
Let Magicajax support Chinese! Problem solving is not difficult, the Internet has a lot of relevant articles to solve, here is not much to say, but in the project this method is actually good use,
Ajaxcallhelper.writealert ("Data saved successfully!") ")//When a button is in Ajaxpanel, the registered JavaScript alert script is not a message box, use this to bounce out on the line, understand the framework of the mechanism you know why it pop-up message box, HoHo.
Ajaxcallhelper.write ("EditGrid ();") Invoke the specified JavaScript method remember to add a semicolon.
Http://www.cnblogs.com/NetFans/archive/2007/01/14/620161.html

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.