Solved

Mandatory prefix on asp.net form

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

785 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