programmerGuy
programmerGuy

Reputation: 167

Date text field asp.net

Can anyone lead me in the right direction as to how to set a textbox such as this:

<td><asp:TextBox ID="txtBoxDate" runat="server" CssClass="fields"></asp:TextBox></td>

Into a masked text box that meets this style "mm/dd/yyyy"

Upvotes: 0

Views: 648

Answers (1)

Afzaal Ahmad Zeeshan
Afzaal Ahmad Zeeshan

Reputation: 15860

Why not just simply convert the DateTime object to that format in server-side code?

Try this

DateTime dateTime = "your-date-time";
var asString = dateTime.ToString("mm/dd/yyyy");

asString will now have the format you've converted the DateTime object to. It will be string. So, after this step you can execute this

txtBoxDate.Text = asString;

..this might be the code you're looking for.

Upvotes: 2

Related Questions