Setfocus ไปยัง Control ต่างๆ ใน page


ASP.NET Setfocus
สร้าง Sub SetFocusControl ไว้ในส่วนของ Code Behind

Public
Sub SetFocusControl(ByVal ControlName As String)
Dim script As String
= _
"<script language='javascript'>" + _
" var control = document.getElementById('" + _
ControlName + "');" + _
" if( control != null ) {control.focus();}" + _
"</script>"

Page.RegisterStartupScript("Focus", script)

End Sub

เรียกใช้

Private
Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ตัวอย่างให้ไป Focus ที่ TextBox1
SetFocusControl(TextBox1.ClientID)

TextBox1.Text = "Yahooooooooooooo"

End Sub

คำสำคัญ (Tags): #uncategorized
หมายเลขบันทึก: 6596เขียนเมื่อ 7 พฤศจิกายน 2005 22:18 น. ()แก้ไขเมื่อ 3 มิถุนายน 2012 19:21 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (0)

ไม่มีความเห็น

พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท