Using firebug in IE
add this script in html page
<script type='text/javascript'
src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>
then run
——————–
JavaScript : Ignore Case Array Sort
When you sort an array in Javascript the array gets sorted into dictionary order. This means that ‘A’ is less than ‘a’ and gets sorted that way. If your array consists of both uppercase and lowercase entries then you probably want to sort alphabetically ignoring the case of the individual entries instead. We can change the way that the array sort method works by passing it a parameter identifying a function that contains the instructions on how to compare the entries.
To sort an array into order ignoring case add the following code (into the head section of your page is probably the most appropriate place):
a = a.toLowerCase(); b = b.toLowerCase();
if (a>b) return 1;
if (a <b) return -1;
return 0; }
function charOrdD(a, b)
a = a.toLowerCase(); b = b.toLowerCase();
if (a<b) return 1;
if (a >b) return -1;
return 0; }
We can now sort the array without the upper and lower case entries being sorted into different orders. The following example shows how:
charArray.sort( charOrdA );
document.write(‘Ascending : ‘ + charArray + ‘<br />’);
charArray.sort( charOrdD );
document.write(‘Descending : ‘ + charArray + ‘<br />’);
Short circuit logic operator
Code Sample
เช่น ต้องการตรวจสอบความยาวของ string s
bitwise หรือ logic operator นั้นจะทำงานได้เร็วกว่าโครงสร้างควบคุมแบบ if( ) และแน่นอนช่วยเพิ่มประสิทธิภาพให้โปรแกรมของคุณ
ทำไมจึงควรใช้ Asychronous script callback และ Page Method แทน Update Panel
การใช้งาน Asynchronize Feature ใน Ajax นั้นสามารถทำได้หลายวิธีด้วยกัน วิธีที่งานและเป็นที่นิยมมากคือการใช้ Update Panel ซึ่งเป็น Control พื้นฐานที่ติดมากับตัว Ajax Extension Module สำหรับ ASP.NET
UpdatePanel นั้นสามารถใข้งานได้งาน เพียงแค่นำส่วนของ Page ที่ต้องการให้เป็น Asynchronous Postback ใส่ไว้ใน Update Panel ก็สามารถทำงานได้แล้วแต่ ตัว UpdatePanel นั้นมีความสามารถในงาน call กลับไปยัง server ได้โดยที่ วงจรชีวิตในการทำงานของ server-side จะเกิดขึ้นปกติเหมือนกับการทำ postback ปกติ ตรงจุดนี้เองทำให้การใช้งาน Updatepanel นั้นจะได้ Performance ที่ต่ำกว่าการเรียกใช้ Webmethod หรือการใช้ Asynchronous layer เรียกไปยัง web service โดยตรง เนื่องจาก WebMethod นั้นจะทำงานโดย JSON ซึ่งเป็นลักษณะหน่ึงของ Web Service ข้อมูลที่ใช้ส่งระหว่างกันจะมีเพียงข้อมูลเป้าหมายที่ต้องการแสดงเท่านั้น แต่ในขณะที่ UpdatePanel นั้นจะทำการ render ทุกๆส่วนภายใน Panel ใหม่ทั้งหมด(ความจริง Render ใหม่ทั้ง Page แต่ว่า write กลับเฉพาะส่วนที่อยู่ภายใน UpdatePanel)
สรุป
การใช้ UpdatePanel นั้นดูเหมือนว่าจะเป็นการเพิ่มความสามารถให้กับหน้า Web Page ของเราแต่กลไกการทำงานของตัวมันเองจะมีลักษณะเดียวกับหน้าที่ไม่เป็น UpdatePanel และอาจจะอันตรายกว่าเนื่องจากการใช้ UpdatePenel เข้าไปช่วยนั้นมักจะทำให้เกิดการส่งข้อมูลบ่อยครั้งกว่าเนื่องจากผู้พัฒนามักเข้าใจผิดว่า server จะทำงานน้อยลง หากผู้พัฒนาต้องการทำเว็บเพจ ที่ต้องการการพิจารณาถึงเรือ่ง performance อยางระมัดระวังแล้ว Web service และ webmethod ดูจะเป็นทางเลือกที่ดีกว่า
ref: http://devstock.exteen.com/20090820/ajax-updatepanel-control
ref: http://devstock.exteen.com/20090820/ajax-updatepanel-control
javascript
Observer Design Pattern Using JavaScript
http://www.codeproject.com/KB/scripting/Observer_Pattern_JS.aspx
Handy XP Style Menu
http://www.codeproject.com/KB/scripting/leftmenu.aspx
AJAX For Beginners
http://www.itechcollege.com/courses/AJAX/
http://www.codeproject.com/KB/scripting/jsbeginner.aspx
http://secure.codeproject.com/KB/scripting/cookies_intro.aspx
http://www.codeproject.com/KB/scripting/Javascript_PageCookie.aspx
JavaScript Convert String number
Question: How do I convert numbers to strings in JavaScript?
Answer: The simplest way to convert any variable to a string is to add an empty string to that variable, for example:
number -> string a = a+'' // This converts a to string b += '' // This converts b to string string -> number eval(a);
javascript replace string
/**
*
* Javascript string replace
* http://www.webtoolkit.info/
*
**/
// standart string replace functionality
function str_replace(haystack, needle, replacement) {
var temp = haystack.split(needle);
return temp.join(replacement);
}
// needle may be a regular expression
function str_replace_reg(haystack, needle, replacement) {
var r = new RegExp(needle, 'g');
return haystack.replace(r, replacement);
}
Object serialization คืออะไร?
คือ การแปลงออปเจคให้อยู่ในรูปของไบต์สตรีม (byte stream)
1. มีไว้เพื่อใช้ในการเก็บออปเจคไว้ในไฟล์ เพื่อเรียกอ่านและแปลงกลับ (deserialization) เป็นออปเจคในภายหลัง เช่น เราเซฟออปเจคที่เก็บข้อมูล application parameter บางตัวไว้ลงในไฟล์หลังจากโปรแกรมจบ เพื่อว่าในการรันโปรแกรมครั้งต่อไปจะได้อ่านพารามิเตอร์เหล่านั้นกลับเข้ามา วิธีนี้ไม่ค่อยเป็นที่นิยมนัก เนื่องจากมีทางเลือกอื่นๆ เช่น เก็บข้อมูลลงในฐานข้อมูล หรือ ใช้ System.Properties หรือใช้ XMLEncoder (ในจาวา 1.4 ขึ้นไป)
2. มีไว้สำหรับเป็นวิธีส่งออปเจคนั้นไปยังเครื่องอื่น เนื่องจากออปเจคถูกแปลงเป็นไบต์สตรีม จึงสามารถส่งออปเจคนั้นไปที่เครื่องอื่น (object distribution) ในกรณีผ่านเป็นพารามิเตอร์ในการ invoke ออปเจคข้ามเครื่อง (เช่นที่ใช้ใน RMI) หรือเป็นการ migrate object ไปรันที่เครื่องอื่น เป็นต้น
———
Stream มีโครงสร้างพื้นฐานเป็นสายของ Byte ที่วิ่งมาเรื่อย ๆ เหมือนกระแสน้ำ นั่นหมายความว่าคุณสามารถเก็บข้อมูลจาก Stream หรือเขียนอะไรลงไปใน Stream คุณต้องทำงานเป็น Byte เสมอ คือก้อนข้อมูลขนาด 0-255 หลาย ๆ ก้อนต่อกัน ผมขอเรียกว่า Byte Stream
ต่อมาเราพบว่า Byte Stream มันใช้งานได้ยากลำบากมาก เพราะเราต้องทำอะไรบางอย่างเพื่อแปลง byte ที่ได้จากการอ่านข้อมูลจาก Stream ให้กลายเป็นสิ่งที่ต้องการ เช่น String และในทางกลับกันเวลาเขียนข้อมูลลงไปใน Stream ก็ต้องแปลงมันให้กลายเป็น byte ทีละ byte ก่อน จึงจะสามารถเขียนข้อมูลลงไปใน Stream ได้ จึงมีการสร้างตัวกรองขึ้นมา (Filter) โดยตัวกรองมีหน้าที่แปลงข้อมูลขาเข้าหรือขาออกตามแต่หน้าที่ เพื่อทำอะไรบางอย่างก่อนจะปล่อยข้อมูลออกมา หรือใส่ข้อมูลเข้าไปใน Stream
Filter จะไม่เปลี่ยนแปลงตัว Raw Data แต่จะทำการแปลงให้อยู่ในรูปแบบที่ใช้งานได้ง่ายขึ้น เช่น
- BufferedInputStream ทำหน้าที่อ่าน Stream มาเยอะ ๆ แล้วเก็บเอาไว้ในหน่วยความจำ แต่เวลาใช้งานเราใช้งานเสมือนว่าข้อมูลยังส่งอยู่ในสายข้อมูล มีประโยชน์ในการ mark/reset เพื่อย้อนกลับไปยังจุดที่เคยอ่านมาก่อน ซึ่ง Stream จริงๆ ไม่ใช่แบบนั้น (สายน้ำย่อมไม่ไหลย้อนกลับ แต่กักตุนได้)
While Loop
var foundOne;
while (foundOne != 0){
foundOne = Math.round(14 * Math.random());
document.write (foundOne + ‘<br>’);
}
Web develop tutorial
http://www.mandarindesign.com/
http://www.mandarindesign.com/boxes.html
*******************
http://www.sitepoint.com/recentarticles/
http://www.sitepoint.com/article/aspnet-performance-tips
http://www.seoconsultants.com/css/menus/tutorial/
http://www.telerik.com/demos/aspnet/Grid/Examples/Overview/DefaultCS.aspx
http://www.amazon.com/gp/product/webstandardsw-20/1590595335/104-6729182-1300737