在winform中很容易實現的,按斷行符號鍵執行相關功能,textchanged事件,還有取得實體路徑,在asp.net中實現起來有點麻煩,此類文章多, 但代碼較亂,特將我使用的這部分代碼貼出來。
讓textbox可以檢測keypress,實現輸入後斷行符號就執行。
另外,本來要實現text changed就清空另一個textbox內容的,發現要焦點離開第一個textbox後才能清除第二個textbox,故改為第一個textbox得到焦點,就清空第二個textbox,所有這些代碼如下所貼(還有取得實體路徑的代碼):public partial class ViewFourConer : PortalModuleBase, IActionable<br />{<br />string m_ApplicationPath = "";<br />string mbTxtPath = "";<br />protected void Page_Load(object sender, EventArgs e)<br />{<br />try<br />{<br />m_ApplicationPath = Request.ApplicationPath;<br />if (this.m_ApplicationPath == "")<br />this.m_ApplicationPath = "/";<br />if (!this.m_ApplicationPath.EndsWith("/"))<br />this.m_ApplicationPath += "/"; //先判斷一下 /<br />mbTxtPath = Server.MapPath(m_ApplicationPath + "DesktopModules/FourConer/mb");<br />輸入.Attributes.Add("OnKeyPress", "EnterTextBox('" + Button1.ClientID + "')");<br />輸入.Attributes.Add("OnFocus", "ClearTextBox('" + 輸出.ClientID + "')");<br />if (!IsPostBack)<br />{<br />}<br />}<br />catch (Exception ex)<br />{<br />Exceptions.ProcessModuleLoadException(this, ex);<br />}<br />}<br />//其他不相關的method就不貼出來了<br />}
<mce:script language="javascript"><!--<br />function EnterTextBox(button)<br />{<br />if(event.keyCode == 13 )<br />{<br />event.keyCode = 9;<br />event.returnValue = false;<br />document.all[button].click();<br />}<br />}<br />function ClearTextBox(textbox)<br />{<br />document.all[textbox].value="";<br />}<br />// --></mce:script>
這幾篇文章不錯,講asp.net中使用工作流程之類的新東西。
http://www.codeproject.com/KB/aspnet/LINQCustomProfileProvider.aspx
http://www.codeproject.com/KB/ajax/MakingGoogleIG.aspx
http://www.codeproject.com/KB/ajax/Web20Portal.aspx