MVC 3.5 Helper


Using the Helper in a Page

  1. In the root folder, create a new blank file called TestHelper.cshtml.
  2. Add the following code to the file:
    <!DOCTYPE html>
        <title>Test Helpers Page</title>
        <p>This is some opening paragraph text.</p>
        <!-- Insert the call to your note helper here. -->
        @MyHelpers.MakeNote("My test note content.")
        <p>This is some following text.</p>

    To call the helper you created, use @ followed by the file name where the helper is, a dot, and then the helper name. (If you had multiple folders in the App_Code folder, you could use the syntax @FolderName.FileName.HelperName to call your helper within any nested folder level). The text that you add in quotation marks within the parentheses is the text that the helper will display as part of the note in the web page.

  3. Save the page and run it in a browser. The helper generates the note item right where you called the helper: between the two paragraphs.

    Screenshot showing the page in the browser and how the helper generated markup that puts a box around the specified text.

DATEDIFF two dates 1 year apart

For a friend who needed to know how to check if two dates in Sybase ASE 12 are a year apart.

A JavaScript Solution

Add moment.js lib

// TODO: Validate if date diff is no more than 1 year
var startSepDt = moment($('#startDateSep').val());
var endSepDt = moment($('#sendDateSep').val());
var dateDiff = endSepDt.diff(startSepDt, 'year');
if (dateDiff > 1) 
       showInValidSeasrchWarning('The date range cannot exceed a year.');
       return false;


A SQL Solution

-- DATEDIFF two dates 1 year apart
DECLARE @year1 datetime, @year2 datetime
SET @year1 = DATEADD(year,-1,GetDate())
SET @year2 = GetDate()
SELeCT @year1, @year2, datediff(year,@year1,@year2) 
if( datediff(year,@year1,@year2) <= 1 AND datediff(dd,@year1, @year2) <= 365 )
print 'Hurray! Within one year..'
print ':( Difference is more than a year'

Android Nano Degree resources

Read your first Android blogpost article

Start by reading this post on the Android Developers blog. It’s written by Google Design Advocate, Roman Nurik, who was the lead designer on the Google I/O 2014 app. Google I/O is an annual conference that Google holds for developers.

Follow official Android Development channels on social media

Aside from the blog, you can get the latest news about Android development via:

Kirill’s Favorite Resources

In addition to the official channels for Android development news, there’s a ton of content online, and a vibrant ecosystem of Android developers who are happy to share their knowledge through blog post articles, social media tips, and conference talks.

Here are some of Kirill’s favorite Android resources:

  • Styling Android blog: A blog that shows off various technical aspects of building design elements of Android apps.
  • Chris Banes’ blog: A blog that gives you a deeper look into Android support libraries.
  • Fragmented Podcast: A weekly podcast filled with Android development discussion.

You can find Kirill on G+, and check out his #pixelpushing series.

%d bloggers like this: