I am using an ASPxDateEdit control for editing of a date field. The time component of this particular field will never be relevant, so I’d like to hide it so that only the date component is visible. I’ve tried the following:
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Date" runat="server" />
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Custom" EditFormatString="M/d/yyyy" runat="server" />
<dx:ASPxDateEdit ID="dpExpirationDate" EditFormat="Custom" EditFormatString="{0:M/d/yyyy}" runat="server" />
I am setting it like this:
dpExpirationDate.Value = Entity.ExpirationDate
No matter what I try, it still shows 7/9/2012 12:00:00 AM. How can I hide the time component?
Also, someone with rep may wat to add ASPxDateEdit as a tag.
Update: I found the problem and it’s very quirky, but what would one expect from a DevExpress control?
I’ve found that setting the ASPxDateEdit’s Visible property to either True or False in the codebehind will cause it to show the time component regardless what you set for its EditFormat property. Also, pushing in a date string will also result in the same effect, so don’t try to assign DateTime.Now.ToString() to its Value property or you will experience the same results.
Your first variant works in my environment. So, set EditFormat attribute value to Date.
EditFormat enumeration values.
As for toggling Visible attribute, I couldn’t reproduce this issue. However, there is an important difference between Visible and ClientVisible attributes. If you set Visible to false, control won’t be rendered. So, you can’t manipulate with it on client side. If you want control to render hidden, you must use ClientVisible attribute.