Find the First and Last Day of the Current Quarter

A very handy piece of code by Karl that finds the first and last day of the current quarter.

C#


DateTime datetime = DateTime.Now;


int currQuarter = (datetime.Month - 1) / 3 + 1;


DateTime dtFirstDay = new DateTime(datetime.Year, 3 * currQuarter - 2, 1);


DateTime dtLastDay = new DateTime(datetime.Year, 3 * currQuarter + 1, 1).AddDays(-1);


 


Response.Write("First Day of Quarter - " + dtFirstDay.ToShortDateString() + " : " +


    "Last Day of Quarter - " + dtLastDay.ToShortDateString());




VB.NET


Dim datetime As DateTime = DateTime.Now


Dim currQuarter As Integer = (datetime.Month - 1) / 3 + 1


Dim dtFirstDay As New DateTime(datetime.Year, 3 * currQuarter - 2, 1)


Dim dtLastDay As New DateTime(datetime.Year, 3 * currQuarter + 1, 1).AddDays(-1)


 


Response.Write("First Day of Quarter - " & dtFirstDay.ToShortDateString() & " : " _


& "Last Day of Quarter - " & dtLastDay.ToShortDateString())


Visual Studio 2010 Beta 1 and .NET 4.0 Beta 1 Now Available for General Public to Download

Visual Studio 2010 Professional and Team System Beta 1 as well as .NET 4.0 Beta 1 are now available to MSDN subscribers as well as general public to download.

MSDN subscribers can download the bits over here.

Non-MSDN subscibers can download the bits over here.

Download Visual Studio 2010 Professional Beta now
Download Visual Studio Team System 2010 Beta now
Other download options

Get an insider view of the features in Visual Studio 2010 by downloading the PDF over here

Adding Crome to Visual Studio 2008 List of Browsers

If you are looking out for the steps to add Crome as a browser while debugging in Visual Studio, then here are these simple steps:

Step 1: Right Click any aspx page in Visual Studio > Browse With. This brings up a 'Browse With' Dialog.

Step 2: Click on 'Add..'. I am on Vista and my Crome.exe is in C:\Users\Suprotim\AppData\Local\Google\Chrome\Application\chrome.exe

Type this path in the program name and give it a friendly name as shown below



Click Ok. Once the browser has been added, you can now view your asp.net pages in Visual Studio using Crome.

Get UserID of the user using ASP.NET Membership

Retreiving the UserId for a user while using the ASP.NET Login controls is very simple, yet it still is one of the most frequently asked questions on the forums. Here's how to do so:

C#


    protected void Page_Load(object sender, EventArgs e)


    {


        System.Web.Security.MembershipUser mu = System.Web.Security.Membership.GetUser();


        string strUsrId = mu.ProviderUserKey.ToString();       


    }




VB.NET


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)


        Dim mu As System.Web.Security.MembershipUser = System.Web.Security.Membership.GetUser()


        Dim strUsrId As String = mu.ProviderUserKey.ToString()


    End Sub


Windows Azure Management Tool

The Windows Azure Management Tool is an invaluable resource to manage storage accounts in Windows Azure by providing features to debug, create, and explore your storage solutions as well as inspect messages in the queues.

As given on the Microsoft site, some features of this tool are:

-Manage multiple storage accounts
-Easily switch between remote and local storage services
-Manage your blobs
-Manage your queues

You can learn more about the Windows Azure Management Tool here.

Find the Actual URL using TinyUrl

TinyURL is a cool service to make long url's short.

However what if you have a TinyURL and now want to preview the actual url. The preview will save you from clicking on a TinyURL that you are not very sure of.

Here's how to do so:

1. Navigate to the Preview Feature of TinyURL.

2. Click on 'Click here to enable previews'. This step adds a cookie to your browser.

3. Now take any TinyURL such as http://tinyurl.com/gridviewtips. To view the actual url, replace the url with the following:

http://preview.tinyurl.com/gridviewtips

You will get the following screen:



You can now preview and proceed to the actual link. Infact as long as the Preview feature is enabled, you do not have to manually use the preview url. Any TinyURL will automatically take you to the Preview URL page.

Using jQuery to Prevent ASP.NET Server Side Events from Occuring

I recently was wiring up the ASP.NET Button control with jQuery and checking out the different events related to the same. I also wanted to see if it was possible to stop a server side event from occuring using jQuery.

For example: I have an ASP.NET button control which causes a postback when it is clicked. However what if you want to check a condition at ClientSide and then allow the postback to occur. Here's how to prevent a postback from occuring using jQuery.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


 


<html xmlns="http://www.w3.org/1999/xhtml">


<head runat="server">


    <title></title>


    <script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>


    <script type="text/javascript">


        $(document).ready(function() {


            $("#<%=Button1.ClientID %>").click(function() {


                // check a condition


                if ("a" == "b")


                    return true;


                else


                    return false;


            });


        });


    </script>


</head>


<body>


    <form id="form1" runat="server">


    <div>


        <asp:Button ID="Button1" runat="server" Text="Click Me"


            onclick="Button1_Click" />


    </div>


    </form>


</body>


</html>


Missed Tech.Ed India? Here's how to catch up with the latest happenings @Tech.Ed

Did you miss out on the biggest technology event Tech.Ed India 2009? Missed out on Steve Ballmer's LIVE keynote? Well you can still catch up with things live as it happens from TechEd India 2009. You can watch all the action from the twitterverse. Here's how:

Official TechEd India 2009 Twitter:
http://twitter.com/techedindia2009

The twitter chatter from community:
http://twitter.com/#search?q=techedin
[Hint: If you want your tweet featured, include the hastag #techedin inyour tweet]

Pictures from TechEd India 2009:
http://www.flickr.com/photos/tags/techedin/

Join Steve Ballmer Live on Stage:
http://virtualtechdays.com/joinsession.aspx

Some community mashups created by attendees:

MVP Blogs from TechEd India:
http://teched.indiamvp.net

TechEd MashUp:
http://baxiabhishek.info/teched/