2011年7月29日 星期五

禁用輸入法

System.Windows.Input.InputMethod.SetIsInputMethodEnabled([要禁用的控制項], false);

2011年7月22日 星期五

解決包在 updatepanel 中的textbox 如果在 server 端呼叫 .focus() 會造成失效或無法輸入中文

改用下面這段取代 focus()
var sScript = "setTimeout(\"$get('" + TextBox1.ClientID + "').focus(); \", 100);";
ScriptManager.RegisterStartupScript(this, this.GetType(), "focus", sScript, true);

PS. 記得不要把ClientIDMode設為"Static",否則會造成整頁刷新的bug
PS. "focus" 針對不同控制項要取不同名稱

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...