問題
如何 使用顯示訊息後focus到TextBox
解決方法
.aspx
.cs
- <script type="text/javascript">
- function alertAfterFocus(message, objID) {
- alert(message);
- window.setTimeout(function() {
- document.getElementById(objID).focus();
- }, 0);
- }
- </script>
how to use
- private void ShowMessage(string msg, string objID)
- {
- msg = msg.Replace("\n", "\\n");
- msg = msg.Replace("\'", string.Empty);
- string message = string.Format("alertAfterFocus('{0}','{1}');", msg, objID);
- ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alert" + System.Guid.NewGuid().ToString(), message, true);
- }
- ShowMessage("xxx must keyin!!", this.textBox1.ClientID);
沒有留言:
張貼留言