Solved

Mandatory prefix on asp.net form

Posted on 2013-11-13
2
361 Views
Last Modified: 2013-11-15
I have a textbox receiving input, and I want to both display a single prefix character, but also prevent the user from erasing it in the textbox.  I'm more familiar with win form development, and know how I'd handle it there.
Is that going to be too complicated in asp.net?  I could simply include it myself, stripping it off if it's included, so I didn't want to go for any complex solution.
0
Comment
Question by:sirbounty
2 Comments
 
LVL 22

Accepted Solution

by:
ambience earned 250 total points
ID: 39647563
There are several ways of doing that in ASP.NET but in every case you resort to client-side javascript to intercept key-press events to modify behavior of the control.

Since jQuery is nicely supported by ASP.NET I would recommend to take a look at any "masked input" plugin for jQuery, or even standalone code. Google for "jquery masked input" and check the first few hits - digitalBash has a nice example.

There is a good chance someone has a masked input server-side control for use in WebForms, but you can easily write a UserControl to wrap everything in one reusable unit.

ASP MVC by default has jQuery integrated so adding a plugin shouldnt be a difficult task.
0
 
LVL 67

Author Closing Comment

by:sirbounty
ID: 39651141
Been a while since I've played with jquery...I'll keep that in the back of my mind.
Thanks for the pointers.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question