PostBackUrl and receiving email problem

ammwebmaster2

New member
Joined
Aug 8, 2006
Messages
2
Programming Experience
Beginner
I am new to Visual Studio and I am stuck on this problem I am having. My page includes a submit button which when the user clicks is supposed to get a thank you page and we are to receive an email with their request. When I put the PostBackUrl to go to the thank you page it goes to the thank you page but I do not receive an email. When I take the PostBackUrl out and submit it it gives me an email but does not go to the thank you page. Can anyone help Please.

:confused:
 
This is shown in the Object Browser regarding the System.Web.UI.WebControls.Button.PostBackUrl property:

Summary:
Gets or sets the URL of the page to post to from the current page when the System.Web.UI.WebControls.Button control is clicked.

Return Values:
The URL of the Web page to post to from the current page when the System.Web.UI.WebControls.Button control is clicked. The default value is an empty string (""), which causes the page to post back to itself.

I'll assume that the code to send the email is in the button's eventHandler. When you click a button, the code isn't executed and then the page posted back, it happens the other way around. The page is posted back and at that point the code is executed. Since you are changing the page that is posted to, the code never executes.

What you can do to correct this is to redirect the response after sending the email:
VB.NET:
Response.Redirect("ThankYouPage.aspx")
Or as an alternative (and what I usually do): have two panels, one containing the Form to collect the user info and another containing the Thank you message. After sending the email simply hide the Form panel and display the ThankYou panel.
 
Or, instead of using 2 panels and doing the switcharound, you could just use a multiview and change the view index.
 
Back
Top