Solved

Mandatory prefix on asp.net form

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

16 Experts available now in Live!

Get 1:1 Help Now