忽略空白文本字段中 [英] Ignore Whitespace in textfield
问题描述
我有我的web应用程序中的文本字段。在这个领域中是一个URL地址,用户可以指定。
I have a text field on my web app. In this field is a url address that user can specify.
如果用户设置了不正确的URL地址,它是用空格pfixed $ P $ www.blablabla.xyz
例如,我想忽略这个和正确的URL将被设置(www.blablabla.xyz
)。在*值是presenting一些方法。
If a user sets an incorrect url address that is prefixed with a space, " www.blablabla.xyz"
for example, I want to ignore this and correct url will be set ("www.blablabla.xyz"
). The * value is presenting some method.
我用<%:.html的*%>
的条件和我有持有这套网址
I use <%: Html.* %>
conditions and I hold this set URL there.
想象这是类似的东西:&LT;%:.html的*(厄运=> doom.MyURL)%>
Imagine this is something like that: <%: Html.*(doom =>doom.MyURL)%>
MyURL是一个字符串值。那么,有没有忽略在这种情况下空格方法?如果是的话,我该怎么办呢?
MyURL is a string value. So is there any method to ignore whitespaces in this case? If yes, how can i do it?
我尝试添加 .Trim()
在 doom.MyURL(doom.MyURL.Trim())
,但这给我一个错误。
I tried add .Trim()
after doom.MyURL (doom.MyURL.Trim())
but this give me an error..
地址:
我想也许我可以编辑MyURL中的.cs声明文件?
现在MyURL定义为:公共字符串MyURL {搞定;设置;}
有没有简单的选项来指定在此的.cs忽略在这里?
Is there any easy option to specify this "ignore" here in .cs ?
推荐答案
试试这个,
yourString.TrimStart(string.WhiteSpace);
这篇关于忽略空白文本字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!