asp.net的textbox在TextMode="MultiLine"的情況下,這時MaxLength的設定會失效,運用JavaScript來結決最簡單明瞭。
1.寫JavrScript Function:
function maxlength(obj, len) {
var mlength = obj.value.length;
if (mlength > len) {
obj.value = obj.value.substring(0, len);
}
}
2.在textbox手動加入onkeyup,並指定第1步寫的JS Function,參數帶入textbox的"本體"及欲限定的字數:
<asp:TextBox ID="txt" runat="server" TextMode="MultiLine" onkeyup="maxlength(this,10);" ></asp:TextBox>
以上,大功告成!!
2015年9月15日 星期二
2015年5月11日 星期一
IIS 設定預先載入
IIS 8.0有個預載入的功能,這個模組可在IIS啟動網站當時就發出一個要求,驅動應用程式先進行初始化,以加快第一個使用者看到內容的時間。
除了啟用預先載入外,還必須要到這個網站使用的應用程式集區的進階設定內,設定啟動模式為AlwaysRunning,這樣才會在應用程式啟動時,觸發應用程式的第一個要求。
2015年5月6日 星期三
子應用程式的web.config不受上層web.config的影響
在Google上看了很多前輩的相關文章,都提到要在上層web.comfig加入
但一直無效,最後在一國外網站找到解決,原來<location path="." inheritInChildApplications="false"></location>不是只框住<system.web></system.web>就好,而是要把會影響到子應用程式的區域都框起來。
例如:
解決方法來源:http://stackoverflow.com/questions/782252/avoid-web-config-inheritance-in-child-web-application-using-inheritinchildapplic
<location path="." inheritInChildApplications="false"> <system.web> </system.web> </location>
但一直無效,最後在一國外網站找到解決,原來<location path="." inheritInChildApplications="false"></location>不是只框住<system.web></system.web>就好,而是要把會影響到子應用程式的區域都框起來。
例如:
<!-- 要遮掉的區域 -->
<location path="." inheritInChildApplications="false">
<connectionStrings>
</connectionStrings>
</location>
<!-- 要留的區域 -->
<appSettings>
</appSettings>
<!-- 要遮掉的區域 -->
<location path="." inheritInChildApplications="false">
<system.web>
<webParts>
</webParts>
<membership>
</membership>
<compilation>
</compilation>
</system.web>
</location>
解決方法來源:http://stackoverflow.com/questions/782252/avoid-web-config-inheritance-in-child-web-application-using-inheritinchildapplic
標籤:
應用程式,
web.config,
web.config互相影響
位置:
台灣
訂閱:
文章 (Atom)


