Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 25, 2009 12:43 AM by Sayre
Member
710 Points
272 Posts
Nov 25, 2008 08:38 AM|LINK
Hi
I have textbox, while page loads, by default this texbox need to be with today's date in "dd/mm/yyyy" format...
Can anyone suggest how to do this using c#.net.
Thanks
avi
C# C# dispose discover C#. NET 2005 C# DateTime c#.net C# 2005 Generics C# code c# 2005 Gridview C# Regular Expressions Byte Arrays c# yield c# memory .net c# .net remoting C# exception c# com interop cast C# type conversion convert.changetype C# in Asp.NET C# .NET Genetic Algorithm Program Code C# code @ C# process copy C#2.0 C# 2005 C# 2008 - Calculator C# 2.0 <C#> c# study course learning
Contributor
4907 Points
836 Posts
Nov 25, 2008 10:04 AM|LINK
<body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </div> </form> </body>
========================
protected void Page_Load(object sender, EventArgs e) { TextBox1.Text = DateTime.Now.ToString("dd/MM/yyyy"); }
Participant
877 Points
294 Posts
well can u use datetimepicker for it?
or
just try... I had taken it from other reference material... credit goes to that unknown author of this code...
dd/mm/yyyy Format In regular Expression (optional mm,optional dd) ([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.][0-9]{4}$ mm/dd/yyyy (optional mm,optional dd) ^([1-9]|0[1-9]|1[012])[- /.]([1-9]|0[1-9]|[12][0-9]|3[01])[- /.][0-9]{4}$ mm/dd/yyyy (Exact Format) ^([01]\d)/([0-3]\d)/(\d{4})$
HTH,
-Prashant
All-Star
31358 Points
4579 Posts
Nov 25, 2008 10:08 AM|LINK
in design mode specify the textbox text as like this
<%= String.Format("{d}", DateTime.Now) %>
259 Points
60 Posts
Nov 25, 2008 10:09 AM|LINK
Hi,,
Very simple...
DateTime.Now.ToString ("dd/MM/yyyy");
Bye
238 Points
79 Posts
Nov 25, 2008 10:20 AM|LINK
trythis:-
txtDate.Text = DateTime.Now.ToShortDateString();
Nov 25, 2008 10:22 AM|LINK
try this:-
txtbox.Text = DateTime.Now.ToShortDateString();
1566 Points
237 Posts
Nov 25, 2008 10:23 AM|LINK
Hi,
Page_Load() event write below code
TextBox.Text = Convert.ToString(DateTime.Now);
Thanks & Regards
Sandeep Reddy Pasham
GGK Technologies , HYD
http://ggktech.com/
1064 Points
173 Posts
Nov 25, 2008 10:29 AM|LINK
With the ToString() method it's very simple.
txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
Regards
120 Points
17 Posts
Nov 25, 2008 10:43 AM|LINK
Hi Friend,
Try This it easy
avicool08
Member
710 Points
272 Posts
how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 08:38 AM|LINK
Hi
I have textbox, while page loads, by default this texbox need to be with today's date in "dd/mm/yyyy" format...
Can anyone suggest how to do this using c#.net.
Thanks
avi
C# C# dispose discover C#. NET 2005 C# DateTime c#.net C# 2005 Generics C# code c# 2005 Gridview C# Regular Expressions Byte Arrays c# yield c# memory .net c# .net remoting C# exception c# com interop cast C# type conversion convert.changetype C# in Asp.NET C# .NET Genetic Algorithm Program Code C# code @ C# process copy C#2.0 C# 2005 C# 2008 - Calculator C# 2.0 <C#> c# study course learning
Abinash Tumulu
Please mark my reply as an
answer
if it helps.
Visit my blog .net Scanner
yeotumitsu@s...
Contributor
4907 Points
836 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:04 AM|LINK
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
========================
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = DateTime.Now.ToString("dd/MM/yyyy");
}
-Manas
=======================================
If this post is useful to you, please mark it as answer.
RutuPrash
Participant
877 Points
294 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:04 AM|LINK
well can u use datetimepicker for it?
or
just try... I had taken it from other reference material... credit goes to that unknown author of this code...
dd/mm/yyyy Format In regular Expression (optional mm,optional dd)
([1-9]|0[1-9]|[12][0-9]|3[01])[- /.]([1-9]|0[1-9]|1[012])[- /.][0-9]{4}$
mm/dd/yyyy (optional mm,optional dd)
^([1-9]|0[1-9]|1[012])[- /.]([1-9]|0[1-9]|[12][0-9]|3[01])[- /.][0-9]{4}$
mm/dd/yyyy (Exact Format)
^([01]\d)/([0-3]\d)/(\d{4})$
HTH,
-Prashant
ramireddyind...
All-Star
31358 Points
4579 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:08 AM|LINK
in design mode specify the textbox text as like this
<%= String.Format("{d}", DateTime.Now) %>
arathi
Member
259 Points
60 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:09 AM|LINK
Hi,,
Very simple...
DateTime.Now.ToString ("dd/MM/yyyy");
Thanks
Bye
ronnyrunatse...
Member
238 Points
79 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:20 AM|LINK
trythis:-
txtDate.Text = DateTime.Now.ToShortDateString();
ronnyrunatse...
Member
238 Points
79 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:22 AM|LINK
try this:-
txtbox.Text = DateTime.Now.ToShortDateString();
sandeepreddi
Participant
1566 Points
237 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:23 AM|LINK
Hi,
Page_Load() event write below code
TextBox.Text = Convert.ToString(DateTime.Now);
Thanks & Regards
Sandeep Reddy Pasham
GGK Technologies , HYD
http://ggktech.com/
Sandeep Reddy P
www.codeintellects.com
http://aspdotnetdevs.blogspot.com
~ Please remember to click Mark as Answer on this post if it helped you ~
aligenius
Participant
1064 Points
173 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:29 AM|LINK
With the ToString() method it's very simple.
txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");
Regards
Dhivakaran
Member
120 Points
17 Posts
Re: how to get date in "dd/mm/yyyy" using C#.net?
Nov 25, 2008 10:43 AM|LINK
Hi Friend,
Try This it easy
DateTime.Now.ToString ("dd/MM/yyyy");
Dhiva
-------------------------------------
Dont Forget to Mark 'ANSWERED' if it helped u