วิธีการ add JavaScript ให้กับ Button ใน Asp.net
How to add JavaScript into Asp.net Button control to confirm user before doing the process
Html control :
<INPUT TYPE=“button” VALUE=“Button1″ ONCLICK=“if(confirm(’Do you want delete?’)){ return true; }else{ return false; }”>
.Net control :
Button1.attribute.Add(“onclick”,”if(confirm(’Do you want delete this item(s)?’)){ return true; }else{ return false; }”);
Have fun
1 Comment
Other Links to this Post
RSS feed for comments on this post. TrackBack URI
By jay, 16/09/2008 @ 14:14
การอ่านค่า Form ใน Asp.net
จะต้องอ้างถึง ID ของ Control แต่ละตัวดัวย จะไม่เหมือนกับ PHP หรือ Asp Classic ที่สามารถอ่าน Array จาก Html control ได้ เช่น name[]
ถ้าเป็น Asp.net จะต้องใช้
var _name = document.getElementById(”< %=name.ClientID%>“).value;
แล้วค่อยเอาค่าใน _name มาใช้