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. Weird behavior on postback

Weird behavior on postback

Scheduled Pinned Locked Moved ASP.NET
databasehelpquestion
2 Posts 1 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.
  • J Offline
    J Offline
    jeff_martin
    wrote on last edited by
    #1

    I have a page with a DropDownList, a TextBox and a button (There is another DropDownList that is hidden). The first DropDownList has a SelectedIndexChanged event defined, which sets the visible properties of the TextBox and second DropDownList (depending on which selection is chosen). The Button has a Click event that runs a stored procedure. The problem I am having is: the first time the page loads, you type something in the TextBox, click the Button and by debugging, I have determined that it goes through the Page_Load (IsPostBack == true) calls the Click event, runs the stored procedure and then for some reason, goes back through the Page_Load (IsPostBack == false), which clears my DataGrid of search results. To the user, it appears that nothing really happened. If you repeat the process of typing in something into the TextBox and click the Button, it works fine. It will work from then on, only doing this on the first time you load the form. Has anyone else experienced this behavior?

    J 1 Reply Last reply
    0
    • J jeff_martin

      I have a page with a DropDownList, a TextBox and a button (There is another DropDownList that is hidden). The first DropDownList has a SelectedIndexChanged event defined, which sets the visible properties of the TextBox and second DropDownList (depending on which selection is chosen). The Button has a Click event that runs a stored procedure. The problem I am having is: the first time the page loads, you type something in the TextBox, click the Button and by debugging, I have determined that it goes through the Page_Load (IsPostBack == true) calls the Click event, runs the stored procedure and then for some reason, goes back through the Page_Load (IsPostBack == false), which clears my DataGrid of search results. To the user, it appears that nothing really happened. If you repeat the process of typing in something into the TextBox and click the Button, it works fine. It will work from then on, only doing this on the first time you load the form. Has anyone else experienced this behavior?

      J Offline
      J Offline
      jeff_martin
      wrote on last edited by
      #2

      I figured out the problem. The page in question was the default page for the directory. If you just entered the directory path without the actual filename, it would load the page. Then when you did the post back it would redirect to the default page again. If you enter the full path with filename, the problem does not occur.

      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