how to get date in "dd/mm/yyyy" using C#.net?

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


Thanks and Regards
Avinash

avicool08@gmail.com
0
avicool08
11/25/2008 9:38:20 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

10 Replies
1263 Views

Similar Articles

[PageSpeed] 36

 <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");
    }


Hope it helps.

-Manas

=======================================
If this post is useful to you, please mark it as answer.
0
yeotumitsu
11/25/2008 11:04:24 AM

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 

0
RutuPrash
11/25/2008 11:04:50 AM

 in design mode specify the textbox text as like this

<%= String.Format("{d}", DateTime.Now) %>


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
11/25/2008 11:08:26 AM

 Hi,,

Very simple...

DateTime.Now.ToString ("dd/MM/yyyy");

Thanks

Bye

 

0
arathi
11/25/2008 11:09:10 AM

trythis:-

txtDate.Text = DateTime.Now.ToShortDateString();

0
ronnyrunatserver
11/25/2008 11:20:47 AM

 try this:-

txtbox.Text = DateTime.Now.ToShortDateString();

0
ronnyrunatserver
11/25/2008 11:22:43 AM

Hi,

 

 Page_Load() event write below code

 TextBox.Text = Convert.ToString(DateTime.Now);

 

 

Thanks & Regards

Sandeep Reddy Pasham

GGK Technologies , HYD

http://ggktech.com/


Thanks & Regards
Sandeep Reddy Pasham
GGK Technologies, Hyd
www.ggktech.com
http://aspdotnetdevs.blogspot.com
~ Please remember to click Mark as Answer on this post if it helped you ~
0
sandeepreddi
11/25/2008 11:23:49 AM

With the ToString() method it's very simple.

txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

Regards

0
aligenius
11/25/2008 11:29:37 AM

Hi Friend,

Try This  it easy

DateTime.Now.ToString ("dd/MM/yyyy");


Regards
Dhiva

-------------------------------------
Dont Forget to Mark 'ANSWERED' if it helped u
0
Dhivakaran
11/25/2008 11:43:26 AM

 Thanks,

It works perfect for me. 

system.datetime.now.tostring("dd/MM/yyyy");


VISHAL PAREKH
0
vrparekh
12/13/2008 6:00:47 AM
Reply:

Similar Artilces:

Developed C#.net WebService 1.1 for Client C#.net 1.1. Getting error "Server was unable to process the Request" Pls Help
Hi., I developed Microsoft C#.net Web Services2003 for the Client Application C#.net 2003. When it runs in 5 machines it gives good performance and has no errors. But if i run the same application in about 80 client machines. Getting error "Server was unable to process the request". I use Sql Server 2005 as my database. I get error even when i login at a time for about 25 users. Tried modifying machine.config too. But went unsuccessful. Live Server is 2003 using IIS 6.0 I use very expensive data handling.  Its very urgent pls help. Have to post in Live Server. Thank u., ...

Keep getting..."Unable to get project file from server",when using vs.net
When trying to open any existing asp.net project in Visual Studio it keeps giving me the message above. It is also throwing an error when I create the project in the first place, it happens when a dos window is opened, the text in the dos window is running "Common Language Runtime Minidump Utility version 1.0.3705.0" and then VS craps out says there was an error and shuts down. I've re-installed the .net components and framework with no avail, and FrontPage extensions etc.. are all installed. I'm running XP professional and have installed IIS 5.1. This is driving me fec...

C#.Net "Double" and "double" When/Where to use?
Hi all     Please let me know the difference between "Double" and "double" in c#.Net (I understand that "Double" is structure      and "double" is an instance to that structure) differences if any thing else.     Also the context in which both has been used.(When/Where to use both). thanks all...      hi,my brains says Double is reference type & double is value type.regards,satishKind Attn: If a reply to your post helped you, kindly mark it as Answered.__________...

Get "Mail"/"Get "News" / "Write"/"Post" buttons?
If the "Get Mail" button text changed to "Get News", and "Write" changed to "Post" when TB's in the news-reading mode, it would save me and probably others from constantly forgetting to make the change before proceeding. :-) Or is there an extension to do this which I don't know about? Thanks! Bob Bob P wrote: > If the "Get Mail" button text changed to "Get News", and "Write" > changed to "Post" when TB's in the news-reading mode, it would save me > and probably others...

Hide "NET USE" C:\Windows\System32\net.exe prompt
--____HXVYWAWXUSKEVXKBAEOI____ Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable On our logon script I'm currently mapping NetWare shares using the MAP = command and Windows shares using the NET USE command. Everything is = working fine and well its just that I'd like to completely hide the = windows command prompt box at login. Close as I've come to a recommendation= was to minimize it but not to completely hide it. as a example of what I'm currently doing: @CMD /C START /M NET USE R: = \\servername\sharename "@C...

Getting an "Unknown runtime error" when using Sys.Net.WebRequest
Hi,I'm trying to use Sys.Net.WebRequest to implement incremental page display (as described in this video: http://www.asp.net/learn/ajax-videos/video-120.aspx). Basically, I'm trying to inject the HTML from one aspx page into a div on another aspx page.The page request works just fine, but when I try to set the div's innerHTML to the value returned by get_responseData(), I'm getting an "Unknown runtime error". I found a forum post that suggested that this might be due to adding a second form tag to the page, but this wasn't a problem in the video I linked to abo...

vb.net get FirstName, LastName using "userprofileservice.asmx"
  Dear All, I am new for vb.net. and I was trying this link and its work well http://forums.asp.net/AddPost.aspx?ForumID=28 Is that possible to use (Web references) http://serverxxx/_vti_bin/userprofileservice.asmx?wsdl and get FirstName, LastName, Office, Email... from Active Directory as well. I am using Infopath to get those details, But wanna try using vb.net to do that. Thanks Lasantha...

What is the use of "Get" and "Set" and how it works?
I'm trying to figure out one part of the code which I found for paging. After looking at them and search other articles about this, I still couldn't understand how this "Get" and "Set" works. Can someone provide me a simple explaination how it works and why we need it? Thanks.1 Public Property CurrentPage() As Integer 2 Get 3 Dim o As Object = ViewState("_CurrentPage") 4 5 If o Is Nothing Then 6 Return 0 7 Else 8 Return o 9 End ...

does anyone know how i would get <%#Eval("Date", "{0:dddd dd MMMM yy}")%>...
to show TUES 21 AUGUST 07 instead of  Tuesday 21 August 07. Thanks Hi There, Try following: <%#Eval("Date", "{0:ddd dd MMMM yy}")%>... More information: http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htmDC517Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved.  <%#Eval("Date", "{0:ddd dd MMMM yy}").ToUpper%>Regards Mike [MVP - ASP/ASP.NET]My site...

"Get Mail" vs "Get All New Messages"
I have a few different email accounts set up in Thunderbird, and I'm using the unified view to view them. Recently, I noticed that the "Get Mail" button seems to only retrieve email for the first account (sometimes?). I'd like to click on that button and retrieve email for all of the accounts. I can get the behavior that I want consistently if I pull down the menu for "Get Mail" and select "Get All New Messages", but I'd prefer to get that in a single click if possible. I tried starting from scratch and recreating my profile, but I st...

Feature Request: "Get Extensions" and "Get Themes"
I think that when you click on the "Get Extensions" or "Get Themes" links, it should open depending on your default window-opening behavior. For example, all new windows for me open up in new tabs. However, when I click the "Get" links, they always open in new windows. I can't even find an extension to do this. How hard would this be to incorporate natively? ...

error "Failed to get datetime data" using dw.net 1.0.1
Hello, My situation: I have a vs2005 project with dw.net version 1.0.1 (build 5502), database is asa10. When my regional settings are Dutch(Belgium) I have no problems at all. When the settings are Italian(Italy) I get a "Failed to get datetime" error when I retrieve when my data contains dates. When the date fields are not filled in then I do not get the error. A date of '2008-1-1 08:00:00' also gives errors. When I try to retrieve the same data in the datawindow painter I also get no error. Can anyone help me? Greetings, Mich=E8le DW.net 2.5 is now th...

MaskedEditExtender date format problem ("yyyy-MM-dd" with cultureName="sv-SE" doesn't work)
Hi All, I need to create MaskedEditExtender for Sweden date which uses format "yyyy-MM-dd". I have the following code below. CalendarExtender doesn't work with current MaskedEditExtender. Also the validation doesn't work properly. <asp:TextBox ID="txtFSFV" MaxLength="100" style="width:70px" runat="server" /> <asp:HyperLink ID="hplGetCalendar" NavigateUrl="javascript:void(null)" runat="server"> <img src="~/images/calendar.png" runat...

Whan can i do? make "string" data type convert to "window" data type, and use a "window" name to get it ancestor "window name", thanks! i use pb5
Rich, With a string window name, you can open a window of that type if you need to. You could, of course, query that window object for any attributes. Another option is to use the LibraryExport function to export the definition of the window which is specified by the string. You can then parse the resulting file to get information on the ancestor object. HTH Sanjiv. "Rich" <windows_ce@netease.com> wrote in message news:2Xsr1WW0AHA.178@forums.sybase.com... > > > ...

Web resources about - how to get date in "dd/mm/yyyy" using C#.net? - asp.net.getting-started

Resources last updated: 1/23/2016 9:34:56 AM