"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, June 30, 2011

Introduction to HTML 5

Hi *.*,
As i already explained abt NAV tag in html 5. Today i'm showing what all new in html 5 and how browser support it got

Sunday, June 26, 2011

http-request and -responce handling in server side

On previous post Handling httprequest using jquery. Today Handling that on server side.
Code
Invoke 2 namespace 
  • using System.Net; 
  • using System.IO;

Saturday, June 25, 2011

Jquery Menu with Bounce effect

 Hi *.*,
Last day my friend shared me an interesting Jquery tip on that basic v created an menu with Bounce effect on hover.
Demo

Validating URL using C# with Regular Expression with and without http

Without using Http


    public bool ValidateUrl(string url)
    {
        // regex pattern for url validation string
        Regex RgxUrl = new Regex("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)?/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
        if (RgxUrl.IsMatch(url))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


By Using Http


    private bool ValidateHttpUrl(string url)
    {
        System.Globalization.CompareInfo cmpUrl = System.Globalization.CultureInfo.InvariantCulture.CompareInfo;
        if (cmpUrl.IsPrefix(txtUrl.Text, "http://") == false)
        {
            txtUrl.Text = "http://" + txtUrl.Text;
        }
        Regex RgxUrl = new Regex("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)?/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
        if (RgxUrl.IsMatch(url))
        {
            return true;
        }
        else
        {
            return false;
        }
    }


Have a nice day... 'N happy Coding :)

Wednesday, June 22, 2011

Asynchronous httpway of Handling Data Jquery

 On my old post I shown using JavaScript asynchronous httpway of handling data. It is fast and reliable but I think depending upon effort it not enough. So I dropped their only, on my Current project my client need a fast way to access data. As he not using a dedicated server, he need that otherwise that project will get fucked up so when he prefer I also agree.

Sunday, June 19, 2011

SQL Cheat Sheet

First of all I need to say thanks to sqlauthority.com for sharing this. As I understand the importance, I’m publishing this on here


Have a nice day... 'N happy Coding :)

Friday, June 17, 2011

NAV tag in HTML-5

In this tip, i will show how to use the <nav> tag in HTML5 for web site navigation.The HTML5 is great new version of HTML with great features. I am exploring that in great details for our forthcoming projects. I found a great tag that can be used in all websites for the navigation. <nav> tag defines a area for navigation in whole HTML markup.
The HTML5 specification for nav tag is like following. You can find all the HTML 5 specification here.
The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. Not all groups of links on a page need to be in a nav element only sections that consist of major navigation blocks are appropriate for the nav element. In particular, it is common for footers to have a list of links to various key parts of a site, but the footer element is more appropriate in such cases, and no nav element is necessary for those links.
<nav> tags can be used as navigation area and under it you can put the group of links that will use for navigation of area. For example if you have downloaded the ASP.NET MVC3 tool update with HTML5 then you can see they have defined the navigation area with nav tags like following.
<nav>
    <ul id="menu">
        <li>@Html.ActionLink("Home", "Index", "Home")</li>
        <li>@Html.ActionLink("About", "About", "Home")</li>
    </ul>
</nav>
As you can see in above they putted Home and About link in the navigation. So now its with the nag tag the html mark-up is more readable. Once its loaded in browser it and if you view source it will be populate as groups of link in nav tag like following.
<nav>
               <ul id="menu">
                   <li><a href="/">Home</a></li>
                   <li><a href="/Home/About">About</a></li>
               </ul>
</nav>
So that’s it You can see its very easy to use and now we have very readable and clear markup with HTML5. Happy Programming.


Have a nice day... 'N happy Coding :)

Thursday, June 16, 2011

Creating and Extending a Culture In Asp.net C#

Haven't you ever used a culture and want to extend it by changing e.g. the currency symbol? Haven't you ever want to create a custom culture for formatting purposes? Answers will vary depending on the developer and the users targeted by his application.
Overtime, more and more cultures are started to be supported by the .NET Framework. However, not all cultures of the world are available in .NET. If you want to use a culture that is not available or you want to support a minority with a region you will need to create your custom culture.
Custom cultures and regions can be created with the class System.Globalization.CultureAndRegionInfoBuilder that resides in the assembly sysglobl.dll (you will need to reference it of course.)
Now, we are going to create a custom culture that extends the U.S. English culture. This culture is for New York. We'll step further and change some of the characteristics of the base culture (en-US) to accommodate our needs for a good example.
We'll start by referencing the assembly sysglobl.dll and add a using statement for the namespace System.Globalization.
sysglobl.dll is very tiny assembly. It contains only one class CultureAndRegionInfoBuilder and one enumeration CultureAndRegionModifiers that we will talk about it soon.
Next, we will instantiate a new instance of CultureAndRegionInfo class. That class is the key class for creating/extending a culture. Plus, it allows you to register/unregister your â€Å“baby.” It is required to register your custom culture on the system before you start using it.
CultureAndRegionInfoBuilder builder = new CultureAndRegionInfoBuilder("en-US-NY",
CultureAndRegionModifiers.None);
The constructor of CultureAndRegionInfoBuilder class requires two parameters. The first is the name of the new culture. The second can one of the three values defined by the CultureAndRegionModifiers enumeration. And that parameter is used to identify the new culture.
The values of CultureAndRegionModifiers are:
  • None: For new cultures and the cultures that extends existing ones.
  • Neutral: For neutral cultures such as English, French, etc.
  • Replacement: For the cultures that you intend to be a replacement of existing culture in .NET Framework or even Windows. A replacement culture is like en-US that would replace the existing culture English (United States.)
In cultures world, there's a unique name for every culture. And that name follows the naming convention xx-XX. The first lowercase xx is for language like en (English,) fr (French,) es (Spanish,) and so on. The second uppercase XX is for the country/region like US, FR, and ES. So an example like de-DE is the unique name German in Germany.
There're exceptions to these rules. First, there̢۪re languages like Dhivehi and Konkani that are abbreviated to three letters like div and kok. In addition, there're two neutral cultures zh-CHS and zh-CHT for Simplified and Traditional Chinese; those have three letters for the country. In addition, there're cultures that have the suffix -Cyrl and -Latn for defining the script Cyrillic or Latin. See RFC 1766 Standards.
After instantiating a new object of type CultureAndRegionInfoBuilder you need to initialize its properties with valid values. For the example in our hands, we will load the values from the parent culture en-US because we intend to extend it. Actually, there's no rules to admit in loading the values for the new culture. You can load it from existing culture or you can write it yourself. In addition, we will set the Parent property to the parent culture that we wish to extend.
CultureInfo parent = new CultureInfo("en-US");
builder.LoadDataFromCultureInfo(parent);
builder.LoadDataFromRegionInfo(new RegionInfo("US"));
builder.Parent = parent;
You might review the properties of both CultureInfo and RegionInfo and compare it to the properties of CultureAndRegionInfoBuilder to know exactly why we are loading both objects.
Now comes the hardest part, changing the properties to accommodate our needs and setting the name of the new culture.
builder.RegionEnglishName = "New York";
builder.RegionNativeName = "New York";
builder.CultureEnglishName = "New York (United States)";
builder.CultureNativeName = "New York (United States)";
builder.NumberFormat.CurrencySymbol =  "*";
In the last few lines we changed the region English and its native name English to New York
In addition, we changed the currency symbol from the dollar sign $ to an asterisk *.
Notice the difference between the English name and native name. The native name is the name of the culture in the native language that the culture is supposed to support. For example, French is the English name is and native name is "français".
Here comes the hottest part, registering your new culture:
builder.Register();
You might get an exception of type InvalidOperationException if you tried to re-register it or if you chose a name that's existed and you are not creating a replacement culture.
Now, Test your new culture:
CultureInfo newYork = new CultureInfo("en-US-NY");
double money = 100.99;
Console.WriteLine(money.ToString("C", newYork));
// "C" means currency formatting
Congratulations! You created a new culture and you can see it in action.
There're some things that you need to take into account:
1.    You can unregister your created culture by using the static method Unregister of CultureAndRegionInfoBuilder class.
CultureAndRegionInfoBuilder.Unregister("en-US-NY");
2.    After creating the desired culture and you don’t want to register it immediately (for example) you can save it as XML and load it later.
3.  // Saving the culture
4.  builder.Save("D:New York Culture.xml");
5.  // Loading the saved culture
6.  CultureAndRegionInfoBuilder.CreateFromLdml
("D:\\New York Culture.xml");
7.    Windows saves the custom cultures you create in the folder %windir%\Globalization.
8.    You are not ended using the custom culture in your .NET code only. You can go to Regional and Language Settings in Control Panel and change the culture to your created one and that affects the entire system.
Need more?


Have a nice day... 'N happy Coding :)

Monday, June 6, 2011

Dealing with exception in Asp.net c#

Exceptions are unforeseen errors that happen in our programs. Most of the time, we can, and should, detect and handle program errors in your code. Exception is handling is in build feature of.NET framework which find the errors and helps us in handling them.

Difference between Bug, Error and defect:

Error: Is a fault in the program, syntax or execution.
There are three types of errors
1)    syntactical error: it is deviation from syntax of program
2)    Logical error: it is deviation from logic of the program.
3)    Execution error: this occurs during executing the program.

Thursday, June 2, 2011

Ajax MaskedEdit and Validator Sample.

MaskedEdit is an ASP.NET AJAX extender that attaches to a TextBox control to restrict the kind of text that can be entered. MaskedEdit applies a "mask" to the input that permits only certain types of characters/text to be entered. The supported data formats are: Number, Date, Time, and DateTime. MaskedEdit uses the culture settings specified in the CultureName property More>>
Demo



  • MaskType - Type of validation to perform:
    None - No validation
    Number - Number validation
    Date - Date validation
    Time - Time validation
    DateTime - Date and time validation
  • Mask Characters and Delimiters
    9 - Only a numeric character
    L - Only a letter
    $ - Only a letter or a space
    C - Only a custom character (case sensitive)
    A - Only a letter or a custom character
    N - Only a numeric or custom character
    ? - Any character

    / - Date separator
    : - Time separator
    . - Decimal separator
    , - Thousand separator
    \ - Escape character
    { - Initial delimiter for repetition of masks
    } - Final delimiter for repetition of masks

    Examples:
    9999999 - Seven numeric characters
    99\/99 - Four numeric characters separated in the middle by a "/" 
Code: