Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Unassigned: problem populating maskededitextender with date [28016]

$
0
0
I've upgraded to the latest ajax toolkit and now and having problems with the maskededitextender. It works great when my users are filling out forms but when I try to display the contents of the form later on, I cannot get the dates to populate. I narrowed things down to a small piece of code to demonstrate.
Here is the html for a textbox and mask:
<asp:TextBox ID="tbDOB" runat="server" MaxLength="20"></asp:TextBox>
<asp:MaskedEditExtender ID="MaskedEditDOB" runat="server" Mask="99/99/9999" MaskType="Date" TargetControlID="tbDOB" />

And in the vb.net code behind the page, I simply want to populate that textbox as follows:
tbDOB.text = "1/1/2015"
(Normally, this would be a date retrieved from the database - this is easier to see the issue)

When I load the page, the textbox appears with the mask (__/__/____) but does not put 1/1/2015 in the box.

What am I doing wrong? I swear this was working before I updated the toolkit so perhaps there is a different way to handle dates in the extender? If I get rid of the mask, then the date populates without a problem.

Comments: Yes, I was able to replicate this issue. It seems that ASP.NET detects a page culture in which the date format is not compatible with MaskedEditExtender Date mask. You can check what actual culture is detected by putting a breakpoint at the line where you assign textbox value and checking the Page.Culture and Page.UICulture values. To make sure that the MaskedEditExtender correctly parses the date value, you can force the page culture by adding Culture and UICulture attributes to the Page directive: ``` <%@ Page ... Culture="auto" UICulture="auto" %> ``` or ``` <%@ Page ... Culture="en-US" UICulture="en-US" %> ```

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>