Saturday, 30 August 2014

File Upload By JQuery

How to start uploads with a button click

 we can start uploads files on the click of a button 

$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        add: function (e, data) {
            data.context = $('<button/>').text('Upload')
                .appendTo(document.body)
                .click(function () {
                    data.context = $('<p/>').text('Uploading...').replaceAll($(this));
                    data.submit();
                });
        },
        done: function (e, data) {
            data.context.text('Upload finished.');
        }
    });
});

3 Tire Architecture.

3-Tier architecture is a very well know buzz word in the world of software development whether it web based or desktop based. In this article I am going to show how to design a web application based on 3-tier architecture.
Introduction 
3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL). 

Presentation Layer (UI) 
Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user. 

Business Access Layer (BAL) or Business Logic Layer 
BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo. 

Data Access Layer (DAL) 
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data through out this article.
 
What is Tier and Layer ?
Here I Will explain what is Tire  and Layer we need to clarify the difference between two terms in N-Tier architecture  Tier and Layer. Tier usually means the physical deployment computer. Usually an individual running server is one tier. Several servers may also be counted as one tier, such as server fail-over clustering. By contrast, layer usually means logic software component group mainly by functionality  layer is used for software development purpose. Layer software implementation has many advantages and is a good way to achieve N-Tier architecture. Layer and tier may or may not exactly match each other. Each layer may run in an individual tier. However, multiple layers may also be able to run in one tier. 

Tire:
It indicates a physical separation of components, which may mean different assemblies such as DLL, EXE, etc. 
Layer:
It indicates a physical separation of components, which may mean different assemblies such as DLL, EXE, etc. on the same server or multiple servers.

By using 3-Tier architecture in your project you can achive 

1. Seperation - the functionality is seperated from the data access and presentation so that it is more maintainable 
2. Independence - layers are established so that if one is modified (to some extent) it will not affect other layers. 
3. Reusability - As the layers are seperated, it can exist as a module that can be reused by other application by referencing it. 

Hope this article helped you understanding 3-Tier architecture and desiging it.

Friday, 29 August 2014

How To Generate Dynamic Controls in Asp.net.

Introduction:
Here I will explain how to generate a controls dynamically on button click.
Description:
By Using Place-Holder control I am going to generate Check box controls on the button click.
And How To Dynamically delete the controls.

  PlaceHolder.aspx

  • Steps1: Take PlaceHolder controls.
  • Step2:Take1 Text box to generate no of dynamic controls.
  • Step3:Take 1 button 
PlaceHolder.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class PlaceHolder : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < int.Parse(TextBox1.Text.ToString()); i++)
        {
         CheckBox chk = new CheckBox();
          PlaceHolder1.Controls.Add(chk);
          Button rdb = new Button();
            rdb.Text = "Delete";
            PlaceHolder1.Controls.Add(rdb);
            PlaceHolder1.Controls.Add(new LiteralControl("<br />"));    
        }
        }
        }



Give the no you want to generate controls dynamically.

After Generate the controls if u want to delete click on the delete button to delete dynamically generated buttons.

Copyright © DotNet-Ashok