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