Solved

Mandatory prefix on asp.net form

Posted on 2013-11-13
2
356 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
A simple description of email encryption using a secure portal service. This is one of the choices offered by The Email Laundry for email encryption. The other choices are pdf encryption which creates an encrypted pdf of your email and any attachmen…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now