ความผิดพลาดคืออาจารย์ 2

บันทึก asp.net :: เพิ่ม Java script ขณะ runtime (รับค่ามาจาก code behide แล้ว alert)

Posted by: -xox- on: พฤศจิกายน 22, 2008

1. จาว่าสคริปแบบธรรมดาเขียนใน code behide รับค่ามาใส่ใน popup เราได้ด้วย

Partial Class employee_ss
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Dim X As String = “Alert Fayjaa !!!!”

Me.ClientScript.RegisterClientScriptBlock(GetType(String), “ABC”, “<script language=’javascript’>alert(‘” & X & “‘);</script>”)


End Sub
End Class

ตรง ABC คือ keyname เอาไว้แบ่งแยกสคริป

2. จาว่าสคริปใน asp.net เปิดหน้าใหม่ กำหนดขนาดได้ แต่ทำไมรีเฟรชหน้าเดิม ??

<a href=”JAVASCRIPT:window.open(
‘EmpChild.aspx’, ‘name’ , ‘menubar=yes , location=yes , scrollbar=yes , status=yes ,
resizable=yes ,width=500 , height=500′);” target=”_top”>อัพโหลดรูป</a>

หรือ

<a href=”#” onclick=”javascript:window.open(‘EmpUploadPic.aspx’, ‘_blank’,'top=100, left=100, height=740, width=780, status=no, menubar=no, resizable=no, scrollbars=yes, toolbar=no, location=no, directories=no’);”>
คลิก
</a>

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s