function SetNum(amount, minusBool, integerCount, decimalCount) {
var processString = new String(amount.replace(/[^0-9,.-]/g, ''));
var returnString = new String();
var returnMinus = false;
var returnDecimal = false;
if (minusBool == true) if (processString.charAt(0) == '-') returnMinus = true;
for (i = 0; i < processString.length; i++) {
if (processString.charAt(i) == '.' && returnDecimal == false) {
returnString += processString.charAt(i);
returnDecimal = true;
}
else if (!isNaN(processString.charAt(i))) {
returnString += processString.charAt(i);
}
}
processString = returnString;
returnString = "";
var front = new String();
var back = new String();
var processStringSplit = processString.split('.');
front = processStringSplit[0];
back = "";
if (returnDecimal == true) back = processStringSplit[1];
if (front.length > integerCount) {
var a = front.length - integerCount;
front = front.substring(a, front.length);
}
if (front.length == 0) front = "0";
front = parseInt(front, 10).toString();
var b = 0;
for (i = 0; i < front.length; i++) {
if (b == 3) {
returnString = ',' + returnString;
b = 0;
}
returnString = front.charAt(front.length - 1 - i) + returnString;
b++;
}
if (decimalCount > 0 && returnDecimal == true) {
back = back.substring(0, decimalCount);
returnString = returnString + '.' + back;
}
if (returnMinus == true) returnString = '-' + returnString;
return returnString;
}
Control add OnChange="value=SetNum(value, true, 10, 2)"
2009年5月21日 星期四
2009年5月10日 星期日
File Download
string str = @"~/Download/ExchangeRate@200903270959.txt";
Response.Clear();
Response.ContentType = "application/save-as";
Response.Charset = "UTF-8";
Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(str.Trim()));
Response.WriteFile(str);
Response.End();
Response.Clear();
Response.ContentType = "application/save-as";
Response.Charset = "UTF-8";
Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(str.Trim()));
Response.WriteFile(str);
Response.End();
訂閱:
文章 (Atom)