You must Sign In to post a response.
  • Category: ASP.NET

    What is IsPostBack

    What is the ispostback property of the page.Where we used !ispostback?
  • #261899
    hi,
    Page.IsPostBack Is used to check if the user posted back to the page. Meaning they clicked a button or changed a field in the form that causes it to post back to itself.
    Putting Not usually is used to check the initial load of the page.
    You only need to fill databound fields on the initial load, so you put all your databinding code in the Not page.IsPostBack. The values are saved in the viewstate and can only be read by the form if it gets posted back to itself.
    So, if it is a postback dont do databinding if its not a postback do databinding.

  • #261903
    If not postback is the function which is used in the pageload eveent to know that this s the first time the page is initiated
    so watever u wnat to display in the frst run should be put in within this code

    there are some items whch needs to be shown everytime when u come back to the page
    so have that in the else block

  • #261908
    Returns a value indicating whether the page is being loaded in
    response to a client postback, or if it is being loaded and
    accessed for the first time.

    Syntax

    Script [ bool variable = ] Page.IsPostBack

    Property Value

    This property returns only a boolean value: true if the page is
    being loaded in response to a client postback; otherwise, false.
    Default value is false.
    Remarks

    Use the IsPostBack property to test either of two states:


    1. if the page is being loaded and accessed for the first time
    ( IsPostBack returns false ), or
    2. if the page is being loaded in response to a client
    postback ( IsPostBack returns true ).

    This property is typically used within a Page_Load event handler
    to conditionally execute one or more embedded statements,
    depending on the IsPostBack state when the page is loaded.

    Example

    The following example evaluates IsPostBack on page load, and runs
    the embedded statements only if IsPostBack is not true,
    indicating the page is being accessed for the first time.


    protected void Page_Load ( Object Src, EventArgs E ) {
    if ( !IsPostBack ) {
    string query = "SELECT distinct Type FROM Products";
    mySelect.DataSource = fetchData ( query, "gear" );
    mySelect.DataBind ( );
    }
    }

  • #261910
    The Page_Load subroutine runs EVERY time the page is loaded. If you want to execute the code in the Page_Load subroutine only the FIRST time the page is loaded, you can use the Page.IsPostBack property. If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server
    Syntax

    Script [ bool variable = ] Page.IsPostBack


    Property Value
    This property returns only a boolean value: true if the page is being loaded in response to a client postback; otherwise, false. Default value is false.

    Remarks
    Use the IsPostBack property to test either of two states:

    if the page is being loaded and accessed for the first time ( IsPostBack returns false ), or
    if the page is being loaded in response to a client postback ( IsPostBack returns true ).
    This property is typically used within a Page_Load event handler to conditionally execute one or more embedded statements, depending on the IsPostBack state when the page is loaded.

    Example
    <%@ Page Language="vb" %>
    <html>
    <head>
    <title>IsPostBack property example</title>
    <script runat="server">
    Sub Page_Load()
    If Page.IsPostBack Then
    Message.Text = "PostBack"
    Else
    Message.Text = "Non-PostBack"
    End If
    End Sub
    </script>
    </head>
    <body>
    <form runat="server">
    <asp:button id="post" Text="Post page" runat="server"/>
    <asp:label id="Message" runat="server"/>
    </form>
    </body>
    </html>

  • #261914
    The property gets a boolean value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.

    Uses:
    For example you want to load a dropdown list only once i.e only for the first request then give the condition !IsPostBack()
    and load the dropdown list.

    This makes sure that the dropdown list is not loaded each and everytime when the page is requested or posted back.

  • #262063
    hi...

    Page.IsPostBack Is used to check if the user posted back to the page. Meaning they clicked a button or changed a field in the form that causes it to post back to itself.
    Putting Not usually is used to check the initial load of the page.
    You only need to fill databound fields on the initial load, so you put all your databinding code in the Not page.IsPostBack. The values are saved in the viewstate and can only be read by the form if it gets posted back to itself.
    So, if it is a postback dont do databinding if its not a postback do databinding

  • #262109
    Page.IsPostBack Is used to check if the user posted back to the page. Meaning they clicked a button or changed a field in the form that causes it to post back to itself.
    Putting Not usually is used to check the initial load of the page.

    This property is used to check whether the page is being loaded and accessed for the first time or whether the page is loaded in response to the client postback.
    Example:
    Consider two combo boxes
    In one lets have a list of countries
    In the other, the states.
    Upon selection of the first, the subsequent one should be populated in accordance. So this requires postback property in combo boxes to be true.

  • #263476
    Page.IsPostBack Property

    Gets a value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.

    The Page_Load subroutine runs EVERY time the page is loaded. If you want to execute the code in the Page_Load subroutine only the FIRST time the page is loaded, you can use the Page.IsPostBack property. If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server (i.e. from a button click on a form)

    Use the Page.IsPostBack property to ensure that you only perform page initialization logic when a page is first loaded and not in response to client postbacks.

    Please rate this post, if it is useful for you.

    Thanks & Regards
    Ashok


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.