Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2010, 10:50 AM
Authorized User
 
Join Date: Jul 2010
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

Quote:
Take a look at the final HTML of your form page in the browser. It contains a <form /> from the ASP.NET page and a nested <form /> from your contact form. Nesting forms is not allowed so when you submit the contact form you actually submit your outer form.
That did it. I deleted the default text inbetween the <body></body> tags.

Quote:
Try looking into Cross Page PostBacks. You can set the PostBack URL of a *server side* button to the URL of the page you want to submit to. All other controls in your server side form could be simple HTML controls to avoid having their names and IDs changed.
That helps. I see it uses JavaScript. I have the name and submit button as server controls, as you can see in the email response I got back.

ctl00$ContentPlaceHolder1$Button1: Submit
ctl00$ContentPlaceHolder1$PersonName: Barrack Obama
email: pres@.XXXgov
howfound: THis is a test.

-----------------------------------------------------------------
This e-mail was generated from a form submission on your website: bdtcomp.com at 8/13/2010 7:35:45 AM
GoDaddy servers are in Phoenix Arizona and they aren't on daylight time, hence their time in the summer is California time.

This is a good link in how to send info to the desination page.

http://www.aspdotnetfaq.com/Faq/How-...n-ASP-Net.aspx

But I am having problems with the SourcePage and DesinationPage.

Right now I am using two server controls and I'm returned a Thank you I will get back to you.

I would like it to say Thank you, [Name] I will get back to you. This will personalize it a bit, and I know clients that if I write them some aspx pages would love this.

It is pretty slick inserting the controls into the markup code as well as the design page. I also fixed up my fancy form a bit, though I am going to work more on it. My tab index was off, so anyone that looked at my copy before, just remember to add after the ID the tabindex from 1, 2, 3, ... otherwise you aggrevate the user.;-)

Santaclaus - I have the Visual C# 2008 Step by Step by John Sharp. If I get a 2010 book I think Imar mentioned one by Wrox.
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill

Last edited by btcomp; August 13th, 2010 at 10:53 AM..
 
Old August 13th, 2010, 11:12 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I am sorry, but there is so much text in this post that I am not sure what you're asking. Can you be more concrete?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old August 13th, 2010, 11:31 AM
Authorized User
 
Join Date: Jul 2010
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

Currently when a user clicks the form it goes to: Thank you I will get back to you.

I would like it to say: Thank you, [Name] I will get back to you.

This is the link again that I based my coding on. http://www.aspdotnetfaq.com/Faq/How-...n-ASP-Net.aspx


SourcePage.aspx:

Code:
<form id="form1" runat="server">

        <div>

            First Name:&nbsp;<asp:TextBox ID="FirstName" runat="server"></asp:TextBox><br />

            Last Name:&nbsp;<asp:TextBox ID="LastName" runat="server"></asp:TextBox><br /><br />

            <asp:Button ID="Button1" runat="server" Text="Submit To Destination Page" PostBackUrl="~/CrossPagePostbacks/DestinationPage.aspx" />

        </div>

    </form>
Quote:
When our user clicks the Submit button, all the values from the HTML Form on SourcePage.aspx will be transfered to the DestinationPage.aspx and we will also be able to get reference to the SourcePage.aspx in our DestinationPage with the PreviousPage property like this:

So in our DestinationPage.aspx.cs code-behind we can easily access two TextBox controls on SourcePage.aspx and show them in two label controls like this:

DestinationPage.aspx:

Code:
protected void Page_Load(object sender, EventArgs e)

    {

        // first check if we had a cross page postback

        if ( (PreviousPage != null) && (PreviousPage.IsCrossPagePostBack) )

        {

            Page previousPage = PreviousPage;

            TextBox firstName = (TextBox)previousPage.FindControl("FirstName");

            TextBox lastName = (TextBox)previousPage.FindControl("LastName");

            // we can now use the values from TextBoxes and display them in two Label controls..

            labelFirstName.Text = firstName.Text;

            labelLastName.Text = lastName.Text;

         }

    }
Hope this helps.;-)
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill
 
Old August 13th, 2010, 11:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

But are you still using the classic ASP script to send out the e-mail? If so, CrossPage PostBacks won''t work. You can submit to the ASP page, but you won't hit DestinationPage.aspx as a cross page post back page.

Check out Chapter 9. There are way easier alternatives to do what you need to do. You can find code to send mail starting on page 317, but also spend some time reading the the chapter up to that part.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
btcomp (August 13th, 2010)
 
Old August 13th, 2010, 12:11 PM
Authorized User
 
Join Date: Jul 2010
Posts: 81
Thanks: 10
Thanked 3 Times in 2 Posts
Default

okay thanks. I will leave it as is until I get to that part. ;-)
__________________
Bob
bdtcomp.com
http://lettersfromasoldier.com
Follow me on Twitter
“Success is not final, failure is not fatal: it is the courage to continue that counts.”~Winston Churchill





Similar Threads
Thread Thread Starter Forum Replies Last Post
Before starting ASP.NET Freeshooter ASP.NET 3.5 Basics 5 February 15th, 2008 12:22 PM
Recordset Count starting from 1 till end nouky Classic ASP Databases 24 October 30th, 2006 06:22 PM
starting asp.net LAKESIDE XML 1 January 29th, 2006 11:34 PM
Starting from ASP.NET 1.1/2.0? kalunalan ASP.NET 1.0 and 1.1 Basics 20 February 23rd, 2005 05:10 AM
Starting ASP .NET web applications stripytiger General .NET 6 August 30th, 2004 01:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.