Solved

ASP.Net/C# - I want to replace everything but the last 4 characters of a string to "*".

Posted on 2008-06-23
6
654 Views
Last Modified: 2013-12-16
Hello all.  I need to take a value such as SSN and replace all the values of the string other than the last 4 numbers.  For example, 111111111 to *****1111.  Then I need to also keep the actual value though for an update.  Any ideas?
0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21854141
Are you wanting to change the value for display?
0
 

Author Comment

by:sbornstein2
ID: 21856727
Learned one that is correct I want to change the value of the SSN where it shows just the last 4 digits but then I do need to still have the actual value itself to store on an update.  The page is SSL but they want this.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 21856756
How are you displaying the SSN on the page?
0
 

Author Comment

by:sbornstein2
ID: 21860197
right now it comes back in free text via a web service call.  I need to take that value and mask it and then display it.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 250 total points
ID: 21861570
Do you want to do something like this?

            string ssn = "123-45-6789";

            this.txtSSN.Text = new string('*', ssn.Length - 4) + ssn.Substring(ssn.Length - 4);
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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