Showing posts with label Dot Net. Show all posts
Showing posts with label Dot Net. Show all posts

Monday, November 25, 2013

Generic functionality and sample program.

Generics refers to a technique of writing code for a class without specifying the data type that the class works with.

First we should now why we required generic

Earlier in C# 1.1 we have object programming and there we  can create object  and in case of typesafe and performace we were creating another classes.

In generic basically we are defining the datatype.

Let say.
  class Generic
    {
        T[] itemsType;
        public static string Name ="test";
    }
}
Calling the generic function
   String nameValue = "";
            nameValue = Generic<string>.Name;

Simple generic program:-
Create a class below
class Address {

        public int SrNo { get; set; }
        public string Name { get; set; }

        public Address(int srNoInput, string NameInput)
        {
            this.SrNo = srNoInput;
            this.Name = NameInput;
        }

    }

Use this class through generic functionality

       List<Address> Addresslist = new List<Address>();

            Addresslist.Add( new Address(1,"Fist"));
            Addresslist.Add( new Address(2,"Second"));
            Addresslist.Add( new Address(3,"Third"));

            foreach( Address Add in Addresslist)
            {

                Console.WriteLine("Address Number:- "  +  Add.SrNo);
                Console.WriteLine("Address Name r:- " + Add.Name);


            }



Monday, October 14, 2013

Zip facility (Zip compression) with .NET Framework

This is very simple to create a zip file and extract this through .net framework,Many developers where using third party components like DotnetZip



Zip is one of the most accepted archive file formats. Zip format is supported in almost all operating systems with some built-in name.
  • In Windows operating system it’s implemented by the name “Compressed folders”.
  • In MAC OS it’s implemented by the name “Archive utility”.
Now in .NET we did not have built-in support for implementing Zip compression. Many developers where using third party components like “DotnetZip”. In .NET 4.5, the Zip feature is baked in the framework itself, inside the namespace System.IO.Compression.
The first step is you need to reference two namespaces:
  • System.IO.Compression.FileSystem
  • System.IO.Compression
If you want to Zip files from a folder you can use the CreateFromDirectory function as shown below.
ZipFile.CreateFromDirectory(@"D:\data",@"D:\data.zip");

If you wish to unzip, you can use the ExtractToDirectory function as shown in the below code.
ZipFile.ExtractToDirectory(@"D:\data.zip", @"D:\data\unzip");

Friday, October 11, 2013

How to resolve file uploading issue in asp.net and 404 file not found when upoloading file.

For uploading large size through asp.net below tag need to be added in web.config file.

Under "system.web"

"httpRuntime maxRequestLength="1048576" "

After adding this tag you may get below error.

404 file not found or moved from this location,Page not found

Add below tag in web.config under  "system.webServer"

 "security / requestFiltering  "requestLimits maxAllowedContentLength="104857600""
/requestFiltering/security

Saturday, June 4, 2011

Microsoft Certified Professional.



Finally, I got the badge of a Microsoft Certified Professional :)

Sunday, May 1, 2011

Microsoft Certified Technology Specialist NET Framework 4 Service communication application




Finally, I have completed this exam :)\

I got in-depth learning and details for the below modules.


  1. A solid understanding of WCF in the context of the .NET Framework 4 solution stack
  2. Experience creating service model elements
  3. Experience using WCF to support open and .NET communication
  4. Experience configuring and deploying WCF applications
  5. Experience using Visual Studio tools, tracing tools, SvcUtil, WCF performance monitoring, and IIS/WAS for hosting services
  6. Experience securing WCF applications
  7. A solid understanding of concurrency

Saturday, March 26, 2011

Microsoft Certified Technology Specialist NET Framework 4 Data Access


I'm honoured that I got a certification of Microsoft® Certified Technology Specialist: .NET Framework 4, Data Access.

I have prepared hard for below topics and cleared this exam -
  1. ADO.NET 4 coding techniques and framework components
  2. ADO.NET Data Services LINQ
  3. LINQ to SQL
  4. Entity Framework technologies
  5. Structured Query Language (SQL)
  6. Stored procedures
  7. Database structures/schemas (objects) XML

Saturday, September 4, 2010

Some Important Operation



Get Item Control Value from server Side
Convert.ToString((DataGrdi.Items[e.Item.ItemIndex].FindControl("hdnfield") as HiddenField).Value);

Get Data Kety Values
Convert.ToString(DataGrid.DataKeys[e.Item.ItemIndex].ToString());

Using Of string.IsNullOrEmpty

Call parent function by User control ( by Reflection Class ) Asp.Net V Imp




Here is a simple command to invoke parent function from the User control

this.Page.GetType().InvokeMember("DisplayMessage", System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { txtMessage.Text });


We need this most of the time when applying the facets at the page level. and the child components need to update the parent one,  As an example below.


Friday, May 28, 2010

How to add Skin File and theme in project



In the skin file, you just need to add the exact definitions of the web controls with all the visual attributes you want. You need to add the runat=”server” attribute but beware of adding the ID attribute because that will cause an error. For example, I have a skin file with the following contents

And this file is placed in the App_Themes/DallasTheme folder. Remember that the theme is identified by the theme folder name, in this case, DallasTheme.


After you’ve placed the skin file you need to set a web page to use this Theme. You can enable a Theme for the entire page by setting the Theme attribute of the page equal to the name of the Theme. In this case, it would be

1) <%@ Page Language="VB" Theme="DallasTheme" %>

2)

protected void Page_PreInit(object sender, EventArgs e)
{
    // Applying theme to a particular page

    Page.Theme = "SmokeAndGlass";
}
3) Themes can also be stored in the web.config file which will be applied to the overall application. Themes declared in this file are therefore not required to be declared in any other file under the @Page tag.
<configuration>
<system.web>

 <pages theme=�SmokeAndGlass� />
</system.web>
</configuration>
------------------------------------------------------------------------------------------

Named skins

Skins without SkindID's are called default skins while skins with SkindID's are known as Named skins. Named skins define different layouts for two or more server controls with unique ID's. IDs can be defined in the same file or you can make different files with different ID's, it all depends on your personal approach and likings. SkinID can be referenced to call named skins. Here is an example:

<asp:Label runat="server" ForeColor="#585880" 
   Font-Size="0.9em" Font-Names="Verdana" SkinID="LabelHeader" />


<asp:Label runat="server" ForeColor="#585980" Font-Size="0.8em" 
                       Font-Names="Arial" SkinID="LabelFooter" />

------------------------
<asp:Label id="Header" runat="server" SkinID="LabelHeader" />


<asp:Label id="Header" runat="server" SkinID="LabelFooter" />

--------------

Dynamically applying themes


protected void Page_PreInit(object sender, EventArgs e)
{ 
    string theme = ""; // setting the value to none

    if (Page.Request.Form.Count > 0) 
    {
        // "Themes" is the ID of dropdownlist

        theme = Page.Request["Themes"].ToString(); 
        if (theme == "Default")
        {
            theme = "";
        }
    }
this.Theme = theme; // applying themes to the overall page.

For More Details visit to this link