Wednesday, 27 February 2013

There are situations where we want date time values in different formats like dd/MM/yy, MM/dd/yy, dd/MMM/yyyy etc.


We are using .ToString() method of date time object to get formatted date time string. In this .ToString() method we need to provide string format in which we want to format date. You can also get time in various format like AM, PM and also get Time Zone like +5:30 etc...

Here is example for this.
In this example we provide various different date time formats. You can also change that accordingly your need. You can also use other symbol than "/".

C#. Net Example :

        DateTime objDateTime = new DateTime(2013, 2, 25, 5, 40, 10);
        Response.Write("<b>dd/MM/yy Date Format :</b>" + objDateTime.ToString("dd/MM/yy"));
        Response.Write("<br/>");
        Response.Write("<b>MM/dd/yy Date Format :</b>" + objDateTime.ToString("MM/dd/yy"));
        Response.Write("<br/>");
        Response.Write("<b>dd/MM/yyyy Date Format :</b>" + objDateTime.ToString("dd/MM/yyyy"));
        Response.Write("<br/>");
        Response.Write("<b>dd-MMM-yyyy Format :</b>" + objDateTime.ToString("dd-MMM-yyyy"));
        Response.Write("<br/>");
        Response.Write("<b>dd/MM/yyyy HH:mm:ss Date And Time Format :</b>" + objDateTime.ToString("dd/MM/yyyy HH:mm:ss"));
        Response.Write("<br/>");
        Response.Write("<b>dd/MM/yyyy HH:mm:ss zzz Date And Time Format with time zone :</b>" + objDateTime.ToString("dd/MM/yyyy HH:mm:ss zzz"));
        Response.Write("<br/>");
        Response.Write("<b>dd/MM/yyyy HH:mm:ss tt Date And Time Format :</b>" + objDateTime.ToString("dd/MM/yyyy HH:mm:ss tt"));
        Response.Write("<br/>");
        Response.Write("<br/>");

VB.Net Example :

            Dim objDateTime As New DateTime(2013, 2, 25, 5, 40, 10)
            Response.Write("<b>dd/MM/yy Date Format : </b>" & objDateTime.ToString("dd/MM/yy"))
            Response.Write("<br/>")
            Response.Write("<b>MM/dd/yy Date Format : </b>" & objDateTime.ToString("MM/dd/yy"))
            Response.Write("<br/>")
            Response.Write("<b>dd/MM/yyyy Date Format : </b>" & objDateTime.ToString("dd/MM/yyyy"))
            Response.Write("<br/>")
            Response.Write("<b>dd-MMM-yyyy Format : </b>" & objDateTime.ToString("dd-MMM-yyyy"))
            Response.Write("<br/>")
            Response.Write("<b>dd/MM/yyyy HH:mm:ss Date And Time Format : </b>" & objDateTime.ToString("dd/MM/yyyy HH:mm:ss"))
            Response.Write("<br/>")
            Response.Write("<b>dd/MM/yyyy HH:mm:ss zzz Date And Time Format with time zone : </b>" & objDateTime.ToString("dd/MM/yyyy HH:mm:ss zzz"))
            Response.Write("<br/>")
            Response.Write("<b>dd/MM/yyyy HH:mm:ss tt Date And Time Format : </b>" & objDateTime.ToString("dd/MM/yyyy HH:mm:ss tt"))
            Response.Write("<br/>")
            Response.Write("<br/>")

Output :
Formatted Date Time In Asp.Net
(To view original image , click on image)


Note : Give us your valuable feedback in comments. Give your suggestions in this article so we can update our articles according to that.


Friday, 22 February 2013

There are many situations where in past we did some useful functionality in some stored procedures after that as time goes we forgot that how exactly we had done that functionality and now we want implement that functionality somewhere else and we do not remember where we used, but we know some important keyword or string that we used at that place. At that time this query is useful.

This query searches in all Stored Procedures in database according to given search criteria and give use the search results. In this query we are using sys.sql_modules and sys.objects system tables.

SQL Query : 

SELECT 
        so.[name] AS SP_NAME ,
        so.type_desc AS ROUTINE_TYPE,
        sm.definition AS SP_DEFINITION
FROM sys.sql_modules AS sm
INNER JOIN sys.objects AS so
    ON sm.object_id = so.object_id
WHERE sm.definition LIKE '%Quantity%'
and type='P'

Output :
Sql Query for Search in Stored Procedures
(To view original image , click on image)

This is the very useful SQL Server Scripts.

Note : Give us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.



Tuesday, 19 February 2013

Click Here to Download JQueryCyclePuginDemo.zip

Now a day image slide show is very popular in websites. Earlier we are using Flash for image slide show. But now a days we are using Javascript for making lite weight image slide show. Using JQuery we can make image slide shows with a many variations in slide show.

We are using JQuery Cycle plugin. This plugin provide many options for slide show. You can download cycle plugin here. Download "jquery.cycle.all.js". You can also check it's Functional documentation and FAQs on this link.

Here is example for this.

Wednesday, 13 February 2013

We can create date time object by supplying day , month , year , hour , minute and second values. After creating this date time object we can get datetime in our desire format. like short date , long date etc... We are using "ToShortDateString" , "ToLongDateString" , "ToShortTimeString" and "ToLongTimeString" methods.

This is example for this.
In this example we create date time object with day , month , year , hour , minute and second values and print that generated date time on screen.

C#. Net Example :

        DateTime objDateTime = new DateTime(2013, 2, 13, 5, 40, 10);
        Response.Write("<b>Short Date :</b>" + objDateTime.ToShortDateString());
        Response.Write("<br/>");
        Response.Write("<b>Long Date :</b>" + objDateTime.ToLongDateString());
        Response.Write("<br/>");
        Response.Write("<b>Short Time :</b>" + objDateTime.ToShortTimeString());
        Response.Write("<br/>");
        Response.Write("<b>Long Time :</b>" + objDateTime.ToLongTimeString());

VB.Net Examples :

        Dim objDateTime As New DateTime(2013, 2, 13, 5, 40, 10)
        Response.Write("<b>Short Date :</b>" + objDateTime.ToShortDateString())
        Response.Write("<br/>")
        Response.Write("<b>Long Date :</b>" + objDateTime.ToLongDateString())
        Response.Write("<br/>")
        Response.Write("<b>Short Time :</b>" + objDateTime.ToShortTimeString())
        Response.Write("<br/>")
        Response.Write("<b>Long Time :</b>" + objDateTime.ToLongTimeString())

Output :
Create Date Time Object

For more Beginning .Net articles visit this link.  Click Here...

Note : Give us your valuable feedback in comments. Give your suggestions in this article so we can update our articles according to that.


Thursday, 7 February 2013

New feature in ASP.Net 4.5. HTML5 introduces new data types which also support by ASP.NET 4.5 textbox control. For email validation you do not require any validation controls. We need to just set property of textbox and input type control.

Your browser must support HTML5 if you want to use this feature.

Now ASP.Net supports new attributes in TextMode property. We are going to use "Email" attribute. There are different way to do this email validation in ASP.NET 4.5 and HTML5. But ASP.NET 4.5 Utlimetly converting to HTML5 at a time of rendering.

Here is example for this.

Friday, 1 February 2013

Click to Download C# Example ImageMappedHandlerInCSharp.zip
Click to Download VB.NET Example ImageMappedHandlerInVBNET.zip


Http Handler using ".ashx" file extension and this is very convenient and understandable to all of us. But we can also custom this file extension with our requirement. To make customization in file extension we need to do add class file in "App_Code" folder and this class file implement "IHttpHandler" interface. And also mapping file extension in IIS and add settings in "web.config" file.

This configuration tell the application to show which file extension this handler serves. We can You do this by adding an <httpHandlers> section to the web.config file.
Here is configuration setting :
    <system.web>
      <httpHandlers>
        <add verb="*" path="ImageHandler.img" type="ImageMappedHandler, App_Code"/>
      </httpHandlers>
    </system.web>

This settings direct the application to use the "ImageMappedHandler" class to process incoming requests for ImageHandler.img. We can also specify wildcards for the path. By specifying *.img for the path which indicates that we want the application to use the ImageMappedHandler class to process any request with the
.img file extension. By specifying * indicates that we want all requests to the application to be processed using the handler.

Additional Configuration for IIS 7 :
If we run out web application on IIS 7 then we also must add the <handlers> configuration section to the <system.webServer> configuration section in our application’s config file. When adding the handler configuration in this section, we must also include the name attribute.

Configuration for IIS 7 :
  <system.webServer>
    <handlers>
      <add name="ImageHandler" verb="*" path="ImageHandler.img" type="ImageMappedHandler, App_Code" />
    </handlers>
  </system.webServer>

Now after doing this settings we can directly call ImageHandler.img from browser and we can get image from that.

Here is example for this.