Forms Authentication
Forms Authentication is a process to allow only authenticated user with valid credential to view a particular page or group of pages/folders and stop unauthenticated or anonymous user outside the secure boundary.
Its mainly to protect the particular folder or page from the group of user or particular user. Form authentication stores all the user details inside a cookie.
User details consist of the User roles, User name. However the page is disable cookies function, then it works by passing all the values in Query string.

Windows authentication
Windows authentication is the default authentication method of the ASP.NET application. Windows authentication it will use local windows user and groups to do authentication and authorization for your ASP.NET pages.Web application can use the same security that applies to your windows application which will authenticate to your window like user names, passwords, and permissions. Mainly used for intranet application.
In order to use windows authentication, you need to make sure your web application's hosting and client user's machine meet the requirements. Generally, both the client and server machines should be in the same local network environment, and they should be part of the same Windows domain (or trusted domain).

12:22 AM

Custom page Index for grid view in asp.net

Posted by vijay


Introduction:
In this article you learn about to apply custom page index for grid view...
This Concept is very simple to apply page index using dropdown list. Here i share the code to apply custom paging using dropdown list..


Design Code:
<div>
        <asp:GridView ID="GridView1" runat="server" OnPageIndexChanging="GridView1_PageIndexChanging">
        </asp:GridView>
    </div>
    <div>
        <span style="color: Maroon;">Page Index </span>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        </asp:DropDownList>
    </div>
Server code:
protected void Page_Load(object sender, EventArgs e)
   
    {
        if (!IsPostBack)
        {
            bindgrid();
            for (Int64 i = 0; i < GridView1.PageCount; i++)
            {
                DropDownList1.Items.Add(i.ToString());
            }
    
        }
    }

void bindgrid()
    {
        //Write the code for bind the data in grid view.
        GridView1.AllowPaging = true;
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }        



Here we write the code selected change event for dropdown and grid view index change
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridView1.PageIndex = DropDownList1.SelectedIndex;
        GridViewPageEventArgs ea = new GridViewPageEventArgs(GridView1.PageIndex);
        GridView1_PageIndexChanging(sender, ea);
          }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        bindgrid();
       
    }

I hope you like this article. Post your comment here..



Introduction:
Here to create control dynamically in asp.net. Also to apply the click event for created control in grid view.

In a previous post i have written to create control in normal page,


Now here going add in grid view control. In many cases we need to work with dynamic data, in that case dynamic control is needed.

Here i illustrate with an example to dynamically add a button control in asp.net
I start the sample code with page init event..
In that page init event we need to bind the data value in grid view. So here I write the function to get the data from database..
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        loadde()
    End Sub

Sub loadde()
         'Here write the code Bind the data into dt
        Dim bnd As New BoundField
        bnd.HeaderText = "Phone"
        bnd.DataField = "Number"
        GridView1.Columns.Add(bnd)
        Dim bnd1 As New BoundField
        bnd1.HeaderText = "Name"
        bnd1.DataField = "Name"
        GridView1.Columns.Add(bnd1)
        Dim bnd2 As New BoundField
        bnd1.HeaderText = "Control"
        GridView1.Columns.Add(bnd2)
        GridView1.DataSource = dt
        GridView1.DataBind()
    End Sub

  
Next we have to add the below code in data bound event .In that below code describe to add new button in each row in grid view….

Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound
        For Each row As GridViewRow In GridView1.Rows
            Dim lnk As New LinkButton
            lnk.Text = "button"
            lnk.ID = "lnkbtn"
            lnk.CommandName = "update"
            row.Cells(2).Controls.Add(lnk)
        Next
    End Sub

Here we mention command name as update, when button click on grid view Row updating event will be fired
Here the code for Row updating event….

Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim row1 As GridViewRow = GridView1.Rows(e.RowIndex)
        usrname = row1.Cells(0).Text
        MsgBox(usrname)
    End Sub

When every button clicks the row updating event is fired. Also by adding handler to the button we used to fire the button outside click event. For that to add the code in data bound event

AddHandler lnk.Click, AddressOf lnk_click
Protected Sub lnk_click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
I hope you like this articles………….
Happy programming