ASP.NET 自動反白
Dim iName As New Text.StringBuilder
If Len(TextBox1.Text) > 0 Then
TextBox1.Attributes("onfocus") = "javascript:nameEvent(this.value);"
iName.Append("function nameEvent(str) {")
iName.Append(" document.getElementById('" & TextBox1.ClientID & "').focus();")
iName.Append(" document.getElementById('" & TextBox1.ClientID & "').select();")
iName.Append("}")
'將 JavaScript 字串註冊到頁面中
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "MyScript19", iName.ToString(), True)
End If
TextBox1.Focus()
沒有留言:
張貼留言