asp.netbuttonispostback

ASP.Net button IsPostBack


There is a button on the page which captures the user's selections and calls another page.

For some reason is it raising the !IsPostBack module on the page load event on the page with the button.

This doesn't make sense to me since this is definite a PostBack event when the user clicks the button.

I have provided the code on my button below. Thanks for your help!

<asp:Button ID="selectedList" runat="server" Text="Search" 
     CausesValidation="false" PostBackUrl="~/Listing.aspx"/>

Solution

  • The PostBackURL makes it so that the landing page (~/Listing.aspx) will always detect a !PostBack, even if you are in Listing.aspx itself.

    It's equivalent to creating a button with "Response.Redirect(Request.RawUrl)" hooked into it's click event.