,如果這是一個網頁..
包括2個隱藏變量如下
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HiddenField2" runat="server" />
</div>
包括jQuery和腳本如下
<script type="text/javascript">
$(document).ready(function() {
$('#TextBox1').focus(function() {
$('#TextBox1').val($('#HiddenField1').val());
});
$('#TextBox1').blur(function() {
$('#TextBox1').val($('#HiddenField2').val());
});
});
</script>
設定的各場的後面的代碼
string str = @"C:\Programs\anotherfolder\blabla\thisisatest.xml";
HiddenField1.Value = str;
if (str.Length > 10)
{
TextBox1.Text = "..." + str.Substring(str.Length - 10, 10);
HiddenField2.Value = TextBox1.Text;
}
這將只顯示整個字符串集中在文本框。
這是一個demo它看起來像。
讓或者我知道這是有益的,如果您有任何疑問
什麼是這樣做的呢? –
也許這有助於:http://stackoverflow.com/questions/8403086/long-path-with-ellipsis-in-the-middle – ChrFin
@AJ:所以你看到文件名的末尾不是開頭,因爲這是很多對用戶更有用嗎? – ChrFin