推 GoalBased:你textbox小一點就不會超出了阿.. 05/07 19:46
推 GoalBased:之後 javascript scroll google一下 05/07 20:03
→ ian90911:因為textbox太多了所以不可能縮小 不然使用者會看不到... 05/09 10:26
原本的作法是
protected void tabControl(){
if(string.IsNullOrEmpty(tb1.text))
tb1.focus();
else if(string.IsNullOrEmpty(tb2.text))
tb2.focus();
else if
....
}
但是在ie8,asp.net的focus不知道為何會在這個中間斷掉
焦點就不見了
所以改用js
protected void jsFocus(string clientid) {
string sScript = "setTimeout(\"document.getElementById('" + clientid
+ "').focus(); \", 1);";
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(),
"focus", sScript, true);
}
-------------
protected void tabControl(){
if(string.IsNullOrEmpty(tb1.text))
jsFocus(tb1.ClientID);
else if(string.IsNullOrEmpty(tb2.text))
jsFocus(tb2.ClientID);
else if
....
}
這個在高解析度下可以運作
但就是在低解析度時會把焦點鎖在這個loop
而不能去點上方的選單按鈕
※ 編輯: ian90911 (118.163.27.126), 05/09/2014 10:52:02