Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Cancel a postback

Cancel a postback

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    theJazzyBrain
    wrote on last edited by
    #1

    Dear CPians, I am using the Page.IsPostBack property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:

    if (Page.IsPostBack)
    {
    if (something == true)
    {
    DO SOMETHING TO CANCEL THE POSTBACK
    }
    }

    Is there a way to prevent it of happening? Thanking you in advance

    Jason Kataropoulos

    Excellence is not an act, but a habit!

    Aristotle

    B J M 3 Replies Last reply
    0
    • T theJazzyBrain

      Dear CPians, I am using the Page.IsPostBack property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:

      if (Page.IsPostBack)
      {
      if (something == true)
      {
      DO SOMETHING TO CANCEL THE POSTBACK
      }
      }

      Is there a way to prevent it of happening? Thanking you in advance

      Jason Kataropoulos

      Excellence is not an act, but a habit!

      Aristotle

      B Offline
      B Offline
      badgrs
      wrote on last edited by
      #2

      What exactly do you mean cancel the postback? You could use Response.Redirect() or Response.End() but I don't think thats exactly what your after. Please explain more.

      T 1 Reply Last reply
      0
      • B badgrs

        What exactly do you mean cancel the postback? You could use Response.Redirect() or Response.End() but I don't think thats exactly what your after. Please explain more.

        T Offline
        T Offline
        theJazzyBrain
        wrote on last edited by
        #3

        Actually a redirect would do it. thanx

        Jason Kataropoulos

        Excellence is not an act, but a habit!

        Aristotle

        1 Reply Last reply
        0
        • T theJazzyBrain

          Dear CPians, I am using the Page.IsPostBack property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:

          if (Page.IsPostBack)
          {
          if (something == true)
          {
          DO SOMETHING TO CANCEL THE POSTBACK
          }
          }

          Is there a way to prevent it of happening? Thanking you in advance

          Jason Kataropoulos

          Excellence is not an act, but a habit!

          Aristotle

          J Offline
          J Offline
          Jesse Squire
          wrote on last edited by
          #4

          I may be misunderstanding what you're trying to accomplish, but it sounds to me as if you should be doing your evaluation on the client-side and preventing the form submission rather then trying to evaluate it on the server after the postback has already taken place. More information on what kind of conditions you're evaluating would prove helpful, if you're still interested in gathering opinions.

          --Jesse

          1 Reply Last reply
          0
          • T theJazzyBrain

            Dear CPians, I am using the Page.IsPostBack property. When this evaluates to true, hence I am within a post back, I want, in some cases to cancel the post back. I need to prevent it of happening in case some condition evaluates to true. Example:

            if (Page.IsPostBack)
            {
            if (something == true)
            {
            DO SOMETHING TO CANCEL THE POSTBACK
            }
            }

            Is there a way to prevent it of happening? Thanking you in advance

            Jason Kataropoulos

            Excellence is not an act, but a habit!

            Aristotle

            M Offline
            M Offline
            Marcus J Smith
            wrote on last edited by
            #5

            If there is an event causing the post back it is best to deal with this in that event, not the Page_Load. Then if something isnt the way you want it just exit that sub.


            Cleako

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups