我怎样才能迫使输入一个ASP.NET文本框为大写? [英] How can I force input to uppercase in an ASP.NET textbox?

查看:140
本文介绍了我怎样才能迫使输入一个ASP.NET文本框为大写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个ASP.NET应用程序。我有一个WebForm一个文本框,我想无论用户类型强制转换为大写。我想这样做在前端。你还应该注意,在这个文本框验证控制,所以我想,以确保该解决方案不会与ASP.NET验证干扰。

I'm writing an ASP.NET application. I have a textbox on a webform, and I want to force whatever the user types to upper case. I'd like to do this on the front end. You should also note that there is a validation control on this textbox, so I want to make sure the solution doesn't interfere with the ASP.NET validation.

澄清:
看来,CSS文本转换使用户输入大写的。然而,引擎盖下,它仍然较低的情况下,由于验证控件失败。你看,我的验证控件检查是否输入一个有效的状态code,但是我只用常规的前pression适用于大写字符。

Clarification: It appears that the CSS text transform makes the user input appear in uppercase. However, under the hood, it's still lower case as the validation control fails. You see, my validation control checks to see if a valid state code is entered, however the regular expression I'm using only works with uppercase characters.

推荐答案

为什么不使用CSS和后端的组合?用途:

Why not use a combination of the CSS and backend? Use:

style='text-transform:uppercase' 

在文本框,并在codebehind使用:

on the TextBox, and in your codebehind use:

Textbox.Value.ToUpper();

您也可以很容易地改变在验证你的正则表达式使用小写和大写字母。这可能不是强迫他们大写容易的解决方案。

You can also easily change your regex on the validator to use lowercase and uppercase letters. That's probably the easier solution than forcing uppercase on them.

这篇关于我怎样才能迫使输入一个ASP.NET文本框为大写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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