Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

how do I store the MaskedEdit "/" to my database field?

Posted on 2014-07-16
10
Medium Priority
?
72 Views
Last Modified: 2014-12-23
hi
I'm using <ajaxToolkit:MaskedEditExtender
I need to store my date this format 99/99/9999
I need to store the slash "/" with me
I need to start entering the date from right to left
As long I'm using Arabic hijiri date my date should be store to the database in a nvarchar (10) this way 30/12/1435
Please help
0
Comment
Question by:Mohammad Alsolaiman
  • 5
  • 5
10 Comments
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 40201276
Replace all single '/' with double '//' slash before storage. Date value can be stored in database in international english format - because this is just simple value. You need to store display format instead - this one can tell what and how is this value displayed to user.
0
 

Author Comment

by:Mohammad Alsolaiman
ID: 40201366
I'm newbie to c# , would you write me sample code please .
0
 

Accepted Solution

by:
Mohammad Alsolaiman earned 0 total points
ID: 40201433
Sinisa Vuk
i try what you've wrote bu nuthing happen.
i did it in c# this way
txtReportDate.Text.Substring(4,4) + "/" + txtReportDate.Text.Substring(2,2) + "/" + txtReportDate.Text.Substring(0,2);

Open in new window

it works good
any comment please
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 40201511
This is for date storing, and not mask? ... as you wrote that you need to store a mask.
Think that date should be stored in format: yyyy-MM-dd (into database)

txtReportDate.ToString("yyyy-MM-dd");

Open in new window

0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 40201515
0
 

Author Comment

by:Mohammad Alsolaiman
ID: 40201592
Thank you for the advice
I'm using Arabic hijiri date. And each country has it's own calendar calculation.
So, the best practice to solve this issue is mapping table, contains each Gregorian date and the equivalent Hijiri date. Then do your date calculations in Gregorian, and return with the equivalent Hijiri date.
That was the reason I store the Hijiri date in nvarchar
so I'm storing my Hijiri date as a text 1435/09/19.
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 40201641
If you store as text - then always stick to one format - and you should not get a problem
0
 

Author Comment

by:Mohammad Alsolaiman
ID: 40201666
Yes, my question was is it possible to do these slashes in MaskedEdit? Instead of doing it in c#.
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 40201889
probably you need to set MaskType, CultureName, Format properties:

MaskType="Date"
CultureName="something"
Mask="99/99/9999"
Format="MM/dd/yyyy"

Culture can be set to fixed like "en-GB" or invariant:
....
system.threading.thread.currentthread.currentculture =    
  system.globalization.cultureinfo.invariantculture

Open in new window


example: http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/MaskedEdit/MaskedEdit.aspx
0
 

Author Closing Comment

by:Mohammad Alsolaiman
ID: 40514598
i try experts suggestions but it was not what I need
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

571 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