asp.net中3個常用的功能,直接上代碼

來源:互聯網
上載者:User

 

在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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.