<asp:TextBox ID="TextBox1" runat="server" Style="outline: none; height: 20px; 170px; border: 1px solid gray;" BorderColor="WhiteSmoke" onkeyup='value = value.replace(/(^s*)|(s*$)/g,"");'></asp:TextBox>
onkeyup='value = value.replace(/(^s*)|(s*$)/g,"");'
一输入空格,自动退回.