Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Wednesday, July 9, 2014

Post Back data Processing

Post Back data  Processing:

In this post we talk the nest topic after Event handling is Understand.here we talk about Post back data processing. In this post we see how to do Asp.net page  if post back event occur. how to data process in past back in Asp.net 

Post Back Processing

isPostBack Use the “isPostBack” property to determine if the page is requested the  first time, or caused by a post back.

 Auto post back

 By default, only clicking a button or hitting the enter key in a textbox will cause post back.
 Set the “AutoPostBack” property to “True” to allow more controls to cause post back when the default event is work

Textbox: text is changed and textbox losses focus.Checkbox or radio button: check status is changed. Dropdown list, checkbox list, radio button list: selected item is changed.

<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" />



here we take a Example and trying to show this.we take a dropdown list and protect data which is load at when the page load.we can not want to re- rander data on the drop down select index change.
remember here we can not want to re-load data on dropdownlist select index. for this work we make Event. 

 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)


code for aspx page.


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mypage.aspx.cs" Inherits="mypage" %>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title></title>

</head>

<body>

    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem>lucknow</asp:ListItem>
            <asp:ListItem>Kanpur</asp:ListItem>
            <asp:ListItem>delhi</asp:ListItem>
            <asp:ListItem></asp:ListItem>
        </asp:DropDownList>
    </div>
    </form>
</body>
</html>

Code for aspx.cs page


using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;



public partial class mypage : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {

        }

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}


Related Post :

Reference: