如何在asp.net文本框中保留前导空格 [英] How do I keep leading spaces in an asp.net textbox

查看:76
本文介绍了如何在asp.net文本框中保留前导空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框Web控件,该控件会自动修剪其内容中的所有前导空格,因此,当我收到文本时,它与用户最初写的内容不一样(以防他输入了前导空格)

i have a text-box web control that automatically trims any leading spaces in it's content thus when i get the text it is not the same as what the user had initially written (in case he entered a leading space)

有没有办法禁用此功能

推荐答案

只有一种解决方案可以覆盖默认行为,即您编写了一个javascript函数,该函数将用户输入的内容分配给隐藏"字段,然后您在您的按钮或任何发生的回发事件中捕获该隐藏字段的值

well there is only one solution to override the default behavior of that is that you write a javascript function that assigns whicever the user enters to a Hidden field and then you capture the value of that hidden field in your button or whatever postback event you have

<asp:TextBox runat="server" ID="TextBox1" onkeydown="document.getElementById('HiddenField1').value += this.value" ></asp:TextBox>

致谢

这篇关于如何在asp.net文本框中保留前导空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆