0

PostBack sometimes it works and sometimes it does not. This is my code:

protected void Page_Load(object sender, EventArgs e)
{


    if (!IsPostBack)
    {
        some code here

    }

}

This is the server side:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Page.ascx.cs" Inherits="Controls_Page" %>

The problem that sometimes the postback gets executed and sometimes it does not. Please advise. Thanks.

IT Developer
  • 23
  • 2
  • 10
  • 1
    `IsPostBack` is only true when...it's a postback. If it's not a post back, i.e. a page refresh, GET, etc. it's false. That's what it's supposed to do – Liam Mar 20 '18 at 14:05
  • 2
    On a related note, it's 2018, why are you still using web forms?! If you don't understand this I'm guessing your learning. Don't learn web forms, everyone else stopped using this technology years ago – Liam Mar 20 '18 at 14:06
  • I am requesting some data by clicking on a button, I perform the same action but sometimes post back is true and sometimes it returns false. – IT Developer Mar 20 '18 at 14:14
  • 1
    That's not possible. You must be doing something to trigger a refresh of the page. Please create a [Minimal, Complete, and Verifiable example](http://idownvotedbecau.se/nomcve/) of your problem – Liam Mar 20 '18 at 14:16
  • @Liam You made my day :D sorry for spamming – titech Mar 20 '18 at 14:32

0 Answers0