Email From Forms with asp:panel.(s) Only one panel works?

Discussion in 'ASP .Net' started by Harry, Nov 7, 2003.

  1. Harry

    Harry Guest

    Hi,

    Can anyone help.

    I have a asp.net page (c#), with two panels, both of which have
    asp:textboxes on.
    When I press the first button, the second panel shows fine.
    When I press the button in the second panel, it triggers the script to
    send the form details by email.

    Problem is, the fields from the first panel do not get sent, only the
    fields from the second panel.
    (Weird thing is the line breaks <br> do get sent!)

    At a guess, do I need to add something to the page_load fuction to
    help remember or am i totally the wrong track!

    Below is sample script if anyone can help me out!

    Thanks
    H

    <%@ Page language="C#" %>
    <%@ Import NameSpace="System.Web" %>
    <%@ Import NameSpace="System.Web.Mail" %>
    <script runat="server" language="C#">

    protected void Send_Email(Object Sender, EventArgs e) {
    MailMessage MyMail = new MailMessage();
    MyMail.To = "";
    MyMail.From = "";
    MyMail.BodyFormat = MailFormat.Html;
    MyMail.Subject = "OPTION1 - User Registrations";
    MyMail.Body = Request.Form["bt_tel"] + "<br>" +
    Request.Form["LastName"] + "<br>" +
    Request.Form["LastName"] + "<br>" +
    Request.Form["Address1"] + "<br>" +
    Request.Form["Address2"] + "<br>" +
    Request.Form["Address3"] + "<br>" +
    Request.Form["postcode"] + "<br>" +
    Request.Form["username"] + "<br>" +
    Request.Form["Password"] + "<br>" +
    Request.Form["contact_num"] + "<br>" +
    Request.Form["EmailAddress"];
    //SmtpMail.SmtpServer = "localhost";
    //Response.Flush();
    try{
    SmtpMail.Send(MyMail);
    //Response.Write("Your Email has been sent sucessfully Thank
    You"); //Line removed as don't page will redirect instead. Put line
    back when debugging.
    Response.Redirect("confirm.aspx");
    }
    catch (Exception exc){
    //Response.Redirect("ordererror.aspx");
    Response.Write("Send failure: " + exc.ToString()); // Line
    Removed. Put back when debugging, to have error messgaes displayed.
    Don;t forget to blank out the response redirect command!
    }
    }

    void Page_Load(Object Sender, EventArgs e) {
    panel1.Visible = true;
    panel2.Visible = false;
    }

    void Page2_Visible(Object Sender, EventArgs e) {
    panel1.Visible = false;
    panel2.Visible = true;
    }



    </script>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:panel runat="server" ID="panel1">
    <table width="736" border="0" cellspacing="0" cellpadding="0"
    height="321">
    <tr>
    <td width="736" height="321" valign="top" bgcolor="#FFFFFF"
    class="bodytxt"><span class="Faqmaintext"><strong><br>
    Personal
    Details:<br>
    </strong></span><span class="ORDsmallprint">Items marked with *
    are compulsary.</span> <br>

    <table width="100%" border="0" align="center">
    <tr>
    <td align="right" nowrap class="Faqmaintext">BT Telephone
    Number:</td>
    <td><asp:textbox CssClass="FRMfield" ID="bt_tel"
    runat="server" Width="200" />
    *</td>
    <td><asp:requiredfieldvalidator ControlToValidate="bt_tel"
    Display="Dynamic" EnableClientScript="true" ErrorMessage="Required"
    Font-Name="Arial" Font-Size="x-small" ID="RequiredFieldValidator1"
    runat="server"></asp:requiredfieldvalidator></td>
    </tr>
    <tr>
    <td colspan="3" align="right" nowrap
    class="Faqmaintext">&nbsp;</td>
    </tr>
    <tr>
    <td width="35%" align="right" nowrap
    class="Faqmaintext"><b>First Name:</b></td>
    <td width="30%"><asp:textbox CssClass="FRMfield"
    ID="FirstName" runat="server" Width="200" />
    * </td>
    <td width="35%"><asp:requiredfieldvalidator
    ControlToValidate="FirstName" Display="Dynamic"
    EnableClientScript="true" ErrorMessage="Required" Font-Name="Arial"
    Font-Size="x-small" ID="RequiredFieldValidator2"
    runat="server"></asp:requiredfieldvalidator>
    </td>
    </tr>
    <tr>
    <td align="right" nowrap
    class="Faqmaintext"><b>Surname:</b></td>
    <td><asp:textbox CssClass="FRMfield" ID="LastName"
    runat="server" Width="200" />
    * </td>
    <td><asp:requiredfieldvalidator ID="RequiredFieldValidator3"
    Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    Display="Dynamic" ErrorMessage="Required" ControlToValidate="LastName"
    runat="server" ></asp:requiredfieldvalidator></td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td>&nbsp; </td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right" valign="top" nowrap
    class="Faqmaintext"><b>Address:</b></td>
    <td>
    <asp:textbox CssClass="FRMfield" ID="Address1" Rows="6" runat="server"
    TextMode="SingleLine" Width="200" />
    *</td>
    <td valign="top"><asp:requiredfieldvalidator
    ID="RequiredFieldValidator4" Font-Size="x-small" Font-Name="Arial"
    EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    ControlToValidate="Address1"
    runat="server"></asp:requiredfieldvalidator></td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td><asp:textbox CssClass="FRMfield" ID="Address2" Rows="6"
    runat="server" TextMode="SingleLine" Width="200" /></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">Town:</td>
    <td><asp:textbox CssClass="FRMfield" ID="Address3" Rows="6"
    runat="server" TextMode="SingleLine" Width="200" /></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">Postcode:</td>
    <td><asp:textbox CssClass="FRMfield" ID="postcode"
    runat="server" TextMode="SingleLine" Width="200" />
    *</td>
    <td><asp:requiredfieldvalidator ControlToValidate="postcode"
    Display="Dynamic" ErrorMessage="Required" Font-Name="Arial"
    Font-Size="x-small" ID="rfvpostcode" runat="server" />&nbsp;</td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td></td>
    <td height="30"><div align="left">
    <div align="center"><asp:button ID="btn1" Text="Next
    Step" runat="server" CssClass="FRMfield" OnClick="Page2_Visible"
    ></asp:button></div>

    </td>
    <td></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </asp:panel>
    <asp:panel runat="server" ID="panel2">
    <span class="Faqmaintext"><strong><br>
    User Details:<br>
    </strong></span><span class="ORDsmallprint">Items
    marked with * are compulsary.</span><br>
    <table width="100%" border="0" align="center">
    <tr>
    <td align="right" nowrap class="Faqmaintext">Select
    Username:</td>
    <td><asp:textbox CssClass="FRMfield" ID="username"
    runat="server" TextMode="SingleLine" Width="200" />
    *</td>
    <td><asp:requiredfieldvalidator ID="RequiredFieldValidator5"
    Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    Display="Dynamic" ErrorMessage="Required" ControlToValidate="username"
    runat="server" ></asp:requiredfieldvalidator></td>
    </tr>
    <tr>
    <td colspan="3" align="right" nowrap
    class="Faqmaintext">&nbsp;</td>
    </tr>
    <tr>
    <td width="34%" align="right" nowrap
    class="Faqmaintext"><b>Password:</b></td>
    <td width="29%"><asp:textbox CssClass="FRMfield"
    TextMode="Password" ID="Password" runat="server" Width="200"/>
    *</td>
    <td width="37%"><asp:requiredfieldvalidator
    ID="RequiredFieldValidator6" Font-Size="x-small" Font-Name="Arial"
    EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    ControlToValidate="Password"
    runat="server"></asp:requiredfieldvalidator></td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext"><b>Confirm
    Password: </b></td>
    <td><asp:textbox CssClass="FRMfield" TextMode="Password"
    ID="PasswordConfirm" runat="server" Width="200" />
    *</td>
    <td><asp:requiredfieldvalidator ID="RequiredFieldValidator7"
    Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    Display="Dynamic" ErrorMessage="Required"
    ControlToValidate="PasswordConfirm"
    runat="server"></asp:requiredfieldvalidator>
    <asp:comparevalidator ControlToCompare="Password"
    ID="CompareValidator1" Font-Size="x-small" Font-Name="Arial"
    EnableClientScript="true" Display="Dynamic" ErrorMessage="Your
    passwords do not match" ControlToValidate="PasswordConfirm"
    runat="server"></asp:comparevalidator>
    </td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right" valign="top" nowrap
    class="Faqmaintext">Contact Telephone
    Number:</td>
    <td><asp:textbox CssClass="FRMfield" TextMode="SingleLine"
    ID="contact_num" runat="server" Width="200" />
    *</td>
    <td valign="top">&nbsp;</td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext"><b>
    E-mail:</b></td>
    <td><asp:textbox CssClass="FRMfield" ID="EmailAddress"
    runat="server" Width="200"/></td>
    <td><asp:regularexpressionvalidator
    ID="RegularExpressionValidator1" EnableClientScript="true"
    Display="Dynamic" ErrorMessage="Please enter a valid email address"
    ControlToValidate="EmailAddress"
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    runat="server" Font-Size="x-small"
    Font-Name="Arial"></asp:regularexpressionvalidator></td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td class="Faqmaintext"><div align="center"></div></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="80" colspan="3"><div align="center"
    class="ORDsummary">
    <p>Package Summary</p>
    <p>You have selected
    <font color="#FF0000">OPTION 1 (256k)</font> which wil
    be charged at <font color="#FF0000">&pound;22</font> per month. <br>
    Your Credit/Debit
    card will be charged on the 15th of every month, one
    month in
    advance.<br>
    Press the continue button to proceed to the payment
    pages.</p>
    </div></td>
    </tr>
    <tr>
    <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    <td>&nbsp; </td>
    <td>&nbsp; </td>
    </tr>
    <tr>
    <td height="19" colspan="3" class="ORDsmallprint"><div
    align="center">By
    pressing 'Continue', you agree to abide by the OPTIMUMi <a
    href="#">Terms
    and Conditions</a> of the Broadband service.</div>
    </td>
    </tr>
    <tr>
    <td class="Faqmaintext">&nbsp;</td>
    <td height="30" align="right"><div align="center">
    <asp:button runat="server" OnClick="Send_Email"
    Text="Continue" CssClass="FRMfield"></asp:Button>
    </div>
    </td>
    <td>&nbsp;</td>
    </tr>
    </table>
    </asp:panel>
    </form>
    </body>
    </html>
     
    Harry, Nov 7, 2003
    #1
    1. Advertising

  2. Harry

    Harry Guest

    Hi,

    After reading up on a few things (asp.net beginners manuals!) I had a
    thought about using session variables and such, but then I thought
    isn't asp:panel supposed to negate the need for that?

    Can anyone help me explain the exact workings of ASP:panel along with
    my original question.
    (I did read up on msdn, but that kinda started going over my head!)

    Cheers
    H




    (Harry) wrote in message news:<>...
    > Hi,
    >
    > Can anyone help.
    >
    > I have a asp.net page (c#), with two panels, both of which have
    > asp:textboxes on.
    > When I press the first button, the second panel shows fine.
    > When I press the button in the second panel, it triggers the script to
    > send the form details by email.
    >
    > Problem is, the fields from the first panel do not get sent, only the
    > fields from the second panel.
    > (Weird thing is the line breaks <br> do get sent!)
    >
    > At a guess, do I need to add something to the page_load fuction to
    > help remember or am i totally the wrong track!
    >
    > Below is sample script if anyone can help me out!
    >
    > Thanks
    > H
    >
    > <%@ Page language="C#" %>
    > <%@ Import NameSpace="System.Web" %>
    > <%@ Import NameSpace="System.Web.Mail" %>
    > <script runat="server" language="C#">
    >
    > protected void Send_Email(Object Sender, EventArgs e) {
    > MailMessage MyMail = new MailMessage();
    > MyMail.To = "";
    > MyMail.From = "";
    > MyMail.BodyFormat = MailFormat.Html;
    > MyMail.Subject = "OPTION1 - User Registrations";
    > MyMail.Body = Request.Form["bt_tel"] + "<br>" +
    > Request.Form["LastName"] + "<br>" +
    > Request.Form["LastName"] + "<br>" +
    > Request.Form["Address1"] + "<br>" +
    > Request.Form["Address2"] + "<br>" +
    > Request.Form["Address3"] + "<br>" +
    > Request.Form["postcode"] + "<br>" +
    > Request.Form["username"] + "<br>" +
    > Request.Form["Password"] + "<br>" +
    > Request.Form["contact_num"] + "<br>" +
    > Request.Form["EmailAddress"];
    > //SmtpMail.SmtpServer = "localhost";
    > //Response.Flush();
    > try{
    > SmtpMail.Send(MyMail);
    > //Response.Write("Your Email has been sent sucessfully Thank
    > You"); //Line removed as don't page will redirect instead. Put line
    > back when debugging.
    > Response.Redirect("confirm.aspx");
    > }
    > catch (Exception exc){
    > //Response.Redirect("ordererror.aspx");
    > Response.Write("Send failure: " + exc.ToString()); // Line
    > Removed. Put back when debugging, to have error messgaes displayed.
    > Don;t forget to blank out the response redirect command!
    > }
    > }
    >
    > void Page_Load(Object Sender, EventArgs e) {
    > panel1.Visible = true;
    > panel2.Visible = false;
    > }
    >
    > void Page2_Visible(Object Sender, EventArgs e) {
    > panel1.Visible = false;
    > panel2.Visible = true;
    > }
    >
    >
    >
    > </script>
    > <html>
    > <head>
    > <title>Untitled Document</title>
    > <meta http-equiv="Content-Type" content="text/html;
    > charset=iso-8859-1">
    > </head>
    > <body>
    > <form id="form1" runat="server">
    > <asp:panel runat="server" ID="panel1">
    > <table width="736" border="0" cellspacing="0" cellpadding="0"
    > height="321">
    > <tr>
    > <td width="736" height="321" valign="top" bgcolor="#FFFFFF"
    > class="bodytxt"><span class="Faqmaintext"><strong><br>
    > Personal
    > Details:<br>
    > </strong></span><span class="ORDsmallprint">Items marked with *
    > are compulsary.</span> <br>
    >
    > <table width="100%" border="0" align="center">
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">BT Telephone
    > Number:</td>
    > <td><asp:textbox CssClass="FRMfield" ID="bt_tel"
    > runat="server" Width="200" />
    > *</td>
    > <td><asp:requiredfieldvalidator ControlToValidate="bt_tel"
    > Display="Dynamic" EnableClientScript="true" ErrorMessage="Required"
    > Font-Name="Arial" Font-Size="x-small" ID="RequiredFieldValidator1"
    > runat="server"></asp:requiredfieldvalidator></td>
    > </tr>
    > <tr>
    > <td colspan="3" align="right" nowrap
    > class="Faqmaintext">&nbsp;</td>
    > </tr>
    > <tr>
    > <td width="35%" align="right" nowrap
    > class="Faqmaintext"><b>First Name:</b></td>
    > <td width="30%"><asp:textbox CssClass="FRMfield"
    > ID="FirstName" runat="server" Width="200" />
    > * </td>
    > <td width="35%"><asp:requiredfieldvalidator
    > ControlToValidate="FirstName" Display="Dynamic"
    > EnableClientScript="true" ErrorMessage="Required" Font-Name="Arial"
    > Font-Size="x-small" ID="RequiredFieldValidator2"
    > runat="server"></asp:requiredfieldvalidator>
    > </td>
    > </tr>
    > <tr>
    > <td align="right" nowrap
    > class="Faqmaintext"><b>Surname:</b></td>
    > <td><asp:textbox CssClass="FRMfield" ID="LastName"
    > runat="server" Width="200" />
    > * </td>
    > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator3"
    > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > Display="Dynamic" ErrorMessage="Required" ControlToValidate="LastName"
    > runat="server" ></asp:requiredfieldvalidator></td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td>&nbsp; </td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" valign="top" nowrap
    > class="Faqmaintext"><b>Address:</b></td>
    > <td>
    > <asp:textbox CssClass="FRMfield" ID="Address1" Rows="6" runat="server"
    > TextMode="SingleLine" Width="200" />
    > *</td>
    > <td valign="top"><asp:requiredfieldvalidator
    > ID="RequiredFieldValidator4" Font-Size="x-small" Font-Name="Arial"
    > EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    > ControlToValidate="Address1"
    > runat="server"></asp:requiredfieldvalidator></td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td><asp:textbox CssClass="FRMfield" ID="Address2" Rows="6"
    > runat="server" TextMode="SingleLine" Width="200" /></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">Town:</td>
    > <td><asp:textbox CssClass="FRMfield" ID="Address3" Rows="6"
    > runat="server" TextMode="SingleLine" Width="200" /></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">Postcode:</td>
    > <td><asp:textbox CssClass="FRMfield" ID="postcode"
    > runat="server" TextMode="SingleLine" Width="200" />
    > *</td>
    > <td><asp:requiredfieldvalidator ControlToValidate="postcode"
    > Display="Dynamic" ErrorMessage="Required" Font-Name="Arial"
    > Font-Size="x-small" ID="rfvpostcode" runat="server" />&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td></td>
    > <td height="30"><div align="left">
    > <div align="center"><asp:button ID="btn1" Text="Next
    > Step" runat="server" CssClass="FRMfield" OnClick="Page2_Visible"
    > ></asp:button></div>

    > </td>
    > <td></td>
    > </tr>
    > </table>
    > </td>
    > </tr>
    > </table>
    > </asp:panel>
    > <asp:panel runat="server" ID="panel2">
    > <span class="Faqmaintext"><strong><br>
    > User Details:<br>
    > </strong></span><span class="ORDsmallprint">Items
    > marked with * are compulsary.</span><br>
    > <table width="100%" border="0" align="center">
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">Select
    > Username:</td>
    > <td><asp:textbox CssClass="FRMfield" ID="username"
    > runat="server" TextMode="SingleLine" Width="200" />
    > *</td>
    > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator5"
    > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > Display="Dynamic" ErrorMessage="Required" ControlToValidate="username"
    > runat="server" ></asp:requiredfieldvalidator></td>
    > </tr>
    > <tr>
    > <td colspan="3" align="right" nowrap
    > class="Faqmaintext">&nbsp;</td>
    > </tr>
    > <tr>
    > <td width="34%" align="right" nowrap
    > class="Faqmaintext"><b>Password:</b></td>
    > <td width="29%"><asp:textbox CssClass="FRMfield"
    > TextMode="Password" ID="Password" runat="server" Width="200"/>
    > *</td>
    > <td width="37%"><asp:requiredfieldvalidator
    > ID="RequiredFieldValidator6" Font-Size="x-small" Font-Name="Arial"
    > EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    > ControlToValidate="Password"
    > runat="server"></asp:requiredfieldvalidator></td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext"><b>Confirm
    > Password: </b></td>
    > <td><asp:textbox CssClass="FRMfield" TextMode="Password"
    > ID="PasswordConfirm" runat="server" Width="200" />
    > *</td>
    > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator7"
    > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > Display="Dynamic" ErrorMessage="Required"
    > ControlToValidate="PasswordConfirm"
    > runat="server"></asp:requiredfieldvalidator>
    > <asp:comparevalidator ControlToCompare="Password"
    > ID="CompareValidator1" Font-Size="x-small" Font-Name="Arial"
    > EnableClientScript="true" Display="Dynamic" ErrorMessage="Your
    > passwords do not match" ControlToValidate="PasswordConfirm"
    > runat="server"></asp:comparevalidator>
    > </td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" valign="top" nowrap
    > class="Faqmaintext">Contact Telephone
    > Number:</td>
    > <td><asp:textbox CssClass="FRMfield" TextMode="SingleLine"
    > ID="contact_num" runat="server" Width="200" />
    > *</td>
    > <td valign="top">&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext"><b>
    > E-mail:</b></td>
    > <td><asp:textbox CssClass="FRMfield" ID="EmailAddress"
    > runat="server" Width="200"/></td>
    > <td><asp:regularexpressionvalidator
    > ID="RegularExpressionValidator1" EnableClientScript="true"
    > Display="Dynamic" ErrorMessage="Please enter a valid email address"
    > ControlToValidate="EmailAddress"
    > ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > runat="server" Font-Size="x-small"
    > Font-Name="Arial"></asp:regularexpressionvalidator></td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td>&nbsp;</td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td class="Faqmaintext"><div align="center"></div></td>
    > <td>&nbsp;</td>
    > </tr>
    > <tr>
    > <td height="80" colspan="3"><div align="center"
    > class="ORDsummary">
    > <p>Package Summary</p>
    > <p>You have selected
    > <font color="#FF0000">OPTION 1 (256k)</font> which wil
    > be charged at <font color="#FF0000">&pound;22</font> per month. <br>
    > Your Credit/Debit
    > card will be charged on the 15th of every month, one
    > month in
    > advance.<br>
    > Press the continue button to proceed to the payment
    > pages.</p>
    > </div></td>
    > </tr>
    > <tr>
    > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > <td>&nbsp; </td>
    > <td>&nbsp; </td>
    > </tr>
    > <tr>
    > <td height="19" colspan="3" class="ORDsmallprint"><div
    > align="center">By
    > pressing 'Continue', you agree to abide by the OPTIMUMi <a
    > href="#">Terms
    > and Conditions</a> of the Broadband service.</div>
    > </td>
    > </tr>
    > <tr>
    > <td class="Faqmaintext">&nbsp;</td>
    > <td height="30" align="right"><div align="center">
    > <asp:button runat="server" OnClick="Send_Email"
    > Text="Continue" CssClass="FRMfield"></asp:Button>
    > </div>
    > </td>
    > <td>&nbsp;</td>
    > </tr>
    > </table>
    > </asp:panel>
    > </form>
    > </body>
    > </html>
     
    Harry, Nov 9, 2003
    #2
    1. Advertising

  3. Harry

    Alvin Bruney Guest

    There's nothing special about the asp panel. It has its own quirks but it is
    still regulated by the stateless web environment. You will need viewstate
    attribute on if you want the panel to remember it's state. I don't really
    understand why you need session variables unless you have view state turned
    off and you want to store data to persist against the post backs.
    Did I miss what you were asking?

    --


    -----------
    Got TidBits?
    Get it here: www.networkip.net/tidbits
    "Harry" <> wrote in message
    news:...
    > Hi,
    >
    > After reading up on a few things (asp.net beginners manuals!) I had a
    > thought about using session variables and such, but then I thought
    > isn't asp:panel supposed to negate the need for that?
    >
    > Can anyone help me explain the exact workings of ASP:panel along with
    > my original question.
    > (I did read up on msdn, but that kinda started going over my head!)
    >
    > Cheers
    > H
    >
    >
    >
    >
    > (Harry) wrote in message

    news:<>...
    > > Hi,
    > >
    > > Can anyone help.
    > >
    > > I have a asp.net page (c#), with two panels, both of which have
    > > asp:textboxes on.
    > > When I press the first button, the second panel shows fine.
    > > When I press the button in the second panel, it triggers the script to
    > > send the form details by email.
    > >
    > > Problem is, the fields from the first panel do not get sent, only the
    > > fields from the second panel.
    > > (Weird thing is the line breaks <br> do get sent!)
    > >
    > > At a guess, do I need to add something to the page_load fuction to
    > > help remember or am i totally the wrong track!
    > >
    > > Below is sample script if anyone can help me out!
    > >
    > > Thanks
    > > H
    > >
    > > <%@ Page language="C#" %>
    > > <%@ Import NameSpace="System.Web" %>
    > > <%@ Import NameSpace="System.Web.Mail" %>
    > > <script runat="server" language="C#">
    > >
    > > protected void Send_Email(Object Sender, EventArgs e) {
    > > MailMessage MyMail = new MailMessage();
    > > MyMail.To = "";
    > > MyMail.From = "";
    > > MyMail.BodyFormat = MailFormat.Html;
    > > MyMail.Subject = "OPTION1 - User Registrations";
    > > MyMail.Body = Request.Form["bt_tel"] + "<br>" +
    > > Request.Form["LastName"] + "<br>" +
    > > Request.Form["LastName"] + "<br>" +
    > > Request.Form["Address1"] + "<br>" +
    > > Request.Form["Address2"] + "<br>" +
    > > Request.Form["Address3"] + "<br>" +
    > > Request.Form["postcode"] + "<br>" +
    > > Request.Form["username"] + "<br>" +
    > > Request.Form["Password"] + "<br>" +
    > > Request.Form["contact_num"] + "<br>" +
    > > Request.Form["EmailAddress"];
    > > //SmtpMail.SmtpServer = "localhost";
    > > //Response.Flush();
    > > try{
    > > SmtpMail.Send(MyMail);
    > > //Response.Write("Your Email has been sent sucessfully Thank
    > > You"); //Line removed as don't page will redirect instead. Put line
    > > back when debugging.
    > > Response.Redirect("confirm.aspx");
    > > }
    > > catch (Exception exc){
    > > //Response.Redirect("ordererror.aspx");
    > > Response.Write("Send failure: " + exc.ToString()); // Line
    > > Removed. Put back when debugging, to have error messgaes displayed.
    > > Don;t forget to blank out the response redirect command!
    > > }
    > > }
    > >
    > > void Page_Load(Object Sender, EventArgs e) {
    > > panel1.Visible = true;
    > > panel2.Visible = false;
    > > }
    > >
    > > void Page2_Visible(Object Sender, EventArgs e) {
    > > panel1.Visible = false;
    > > panel2.Visible = true;
    > > }
    > >
    > >
    > >
    > > </script>
    > > <html>
    > > <head>
    > > <title>Untitled Document</title>
    > > <meta http-equiv="Content-Type" content="text/html;
    > > charset=iso-8859-1">
    > > </head>
    > > <body>
    > > <form id="form1" runat="server">
    > > <asp:panel runat="server" ID="panel1">
    > > <table width="736" border="0" cellspacing="0" cellpadding="0"
    > > height="321">
    > > <tr>
    > > <td width="736" height="321" valign="top" bgcolor="#FFFFFF"
    > > class="bodytxt"><span class="Faqmaintext"><strong><br>
    > > Personal
    > > Details:<br>
    > > </strong></span><span class="ORDsmallprint">Items marked with *
    > > are compulsary.</span> <br>
    > >
    > > <table width="100%" border="0" align="center">
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">BT Telephone
    > > Number:</td>
    > > <td><asp:textbox CssClass="FRMfield" ID="bt_tel"
    > > runat="server" Width="200" />
    > > *</td>
    > > <td><asp:requiredfieldvalidator ControlToValidate="bt_tel"
    > > Display="Dynamic" EnableClientScript="true" ErrorMessage="Required"
    > > Font-Name="Arial" Font-Size="x-small" ID="RequiredFieldValidator1"
    > > runat="server"></asp:requiredfieldvalidator></td>
    > > </tr>
    > > <tr>
    > > <td colspan="3" align="right" nowrap
    > > class="Faqmaintext">&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td width="35%" align="right" nowrap
    > > class="Faqmaintext"><b>First Name:</b></td>
    > > <td width="30%"><asp:textbox CssClass="FRMfield"
    > > ID="FirstName" runat="server" Width="200" />
    > > * </td>
    > > <td width="35%"><asp:requiredfieldvalidator
    > > ControlToValidate="FirstName" Display="Dynamic"
    > > EnableClientScript="true" ErrorMessage="Required" Font-Name="Arial"
    > > Font-Size="x-small" ID="RequiredFieldValidator2"
    > > runat="server"></asp:requiredfieldvalidator>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap
    > > class="Faqmaintext"><b>Surname:</b></td>
    > > <td><asp:textbox CssClass="FRMfield" ID="LastName"
    > > runat="server" Width="200" />
    > > * </td>
    > > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator3"
    > > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > > Display="Dynamic" ErrorMessage="Required" ControlToValidate="LastName"
    > > runat="server" ></asp:requiredfieldvalidator></td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td>&nbsp; </td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" valign="top" nowrap
    > > class="Faqmaintext"><b>Address:</b></td>
    > > <td>
    > > <asp:textbox CssClass="FRMfield" ID="Address1" Rows="6" runat="server"
    > > TextMode="SingleLine" Width="200" />
    > > *</td>
    > > <td valign="top"><asp:requiredfieldvalidator
    > > ID="RequiredFieldValidator4" Font-Size="x-small" Font-Name="Arial"
    > > EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    > > ControlToValidate="Address1"
    > > runat="server"></asp:requiredfieldvalidator></td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td><asp:textbox CssClass="FRMfield" ID="Address2" Rows="6"
    > > runat="server" TextMode="SingleLine" Width="200" /></td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">Town:</td>
    > > <td><asp:textbox CssClass="FRMfield" ID="Address3" Rows="6"
    > > runat="server" TextMode="SingleLine" Width="200" /></td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">Postcode:</td>
    > > <td><asp:textbox CssClass="FRMfield" ID="postcode"
    > > runat="server" TextMode="SingleLine" Width="200" />
    > > *</td>
    > > <td><asp:requiredfieldvalidator ControlToValidate="postcode"
    > > Display="Dynamic" ErrorMessage="Required" Font-Name="Arial"
    > > Font-Size="x-small" ID="rfvpostcode" runat="server" />&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td>&nbsp;</td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td></td>
    > > <td height="30"><div align="left">
    > > <div align="center"><asp:button ID="btn1" Text="Next
    > > Step" runat="server" CssClass="FRMfield" OnClick="Page2_Visible"
    > > ></asp:button></div>

    > > </td>
    > > <td></td>
    > > </tr>
    > > </table>
    > > </td>
    > > </tr>
    > > </table>
    > > </asp:panel>
    > > <asp:panel runat="server" ID="panel2">
    > > <span class="Faqmaintext"><strong><br>
    > > User Details:<br>
    > > </strong></span><span class="ORDsmallprint">Items
    > > marked with * are compulsary.</span><br>
    > > <table width="100%" border="0" align="center">
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">Select
    > > Username:</td>
    > > <td><asp:textbox CssClass="FRMfield" ID="username"
    > > runat="server" TextMode="SingleLine" Width="200" />
    > > *</td>
    > > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator5"
    > > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > > Display="Dynamic" ErrorMessage="Required" ControlToValidate="username"
    > > runat="server" ></asp:requiredfieldvalidator></td>
    > > </tr>
    > > <tr>
    > > <td colspan="3" align="right" nowrap
    > > class="Faqmaintext">&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td width="34%" align="right" nowrap
    > > class="Faqmaintext"><b>Password:</b></td>
    > > <td width="29%"><asp:textbox CssClass="FRMfield"
    > > TextMode="Password" ID="Password" runat="server" Width="200"/>
    > > *</td>
    > > <td width="37%"><asp:requiredfieldvalidator
    > > ID="RequiredFieldValidator6" Font-Size="x-small" Font-Name="Arial"
    > > EnableClientScript="true" Display="Dynamic" ErrorMessage="Required"
    > > ControlToValidate="Password"
    > > runat="server"></asp:requiredfieldvalidator></td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext"><b>Confirm
    > > Password: </b></td>
    > > <td><asp:textbox CssClass="FRMfield" TextMode="Password"
    > > ID="PasswordConfirm" runat="server" Width="200" />
    > > *</td>
    > > <td><asp:requiredfieldvalidator ID="RequiredFieldValidator7"
    > > Font-Size="x-small" Font-Name="Arial" EnableClientScript="true"
    > > Display="Dynamic" ErrorMessage="Required"
    > > ControlToValidate="PasswordConfirm"
    > > runat="server"></asp:requiredfieldvalidator>
    > > <asp:comparevalidator ControlToCompare="Password"
    > > ID="CompareValidator1" Font-Size="x-small" Font-Name="Arial"
    > > EnableClientScript="true" Display="Dynamic" ErrorMessage="Your
    > > passwords do not match" ControlToValidate="PasswordConfirm"
    > > runat="server"></asp:comparevalidator>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td>&nbsp;</td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" valign="top" nowrap
    > > class="Faqmaintext">Contact Telephone
    > > Number:</td>
    > > <td><asp:textbox CssClass="FRMfield" TextMode="SingleLine"
    > > ID="contact_num" runat="server" Width="200" />
    > > *</td>
    > > <td valign="top">&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext"><b>
    > > E-mail:</b></td>
    > > <td><asp:textbox CssClass="FRMfield" ID="EmailAddress"
    > > runat="server" Width="200"/></td>
    > > <td><asp:regularexpressionvalidator
    > > ID="RegularExpressionValidator1" EnableClientScript="true"
    > > Display="Dynamic" ErrorMessage="Please enter a valid email address"
    > > ControlToValidate="EmailAddress"
    > > ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    > > runat="server" Font-Size="x-small"
    > > Font-Name="Arial"></asp:regularexpressionvalidator></td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td>&nbsp;</td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td class="Faqmaintext"><div align="center"></div></td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > <tr>
    > > <td height="80" colspan="3"><div align="center"
    > > class="ORDsummary">
    > > <p>Package Summary</p>
    > > <p>You have selected
    > > <font color="#FF0000">OPTION 1 (256k)</font> which wil
    > > be charged at <font color="#FF0000">&pound;22</font> per month. <br>
    > > Your Credit/Debit
    > > card will be charged on the 15th of every month, one
    > > month in
    > > advance.<br>
    > > Press the continue button to proceed to the payment
    > > pages.</p>
    > > </div></td>
    > > </tr>
    > > <tr>
    > > <td align="right" nowrap class="Faqmaintext">&nbsp;</td>
    > > <td>&nbsp; </td>
    > > <td>&nbsp; </td>
    > > </tr>
    > > <tr>
    > > <td height="19" colspan="3" class="ORDsmallprint"><div
    > > align="center">By
    > > pressing 'Continue', you agree to abide by the OPTIMUMi <a
    > > href="#">Terms
    > > and Conditions</a> of the Broadband service.</div>
    > > </td>
    > > </tr>
    > > <tr>
    > > <td class="Faqmaintext">&nbsp;</td>
    > > <td height="30" align="right"><div align="center">
    > > <asp:button runat="server" OnClick="Send_Email"
    > > Text="Continue" CssClass="FRMfield"></asp:Button>
    > > </div>
    > > </td>
    > > <td>&nbsp;</td>
    > > </tr>
    > > </table>
    > > </asp:panel>
    > > </form>
    > > </body>
    > > </html>
     
    Alvin Bruney, Nov 10, 2003
    #3
  4. Harry

    Harry Singh Guest

    I dont think you missed anything, but I think you did clear up my
    question.
    The reason I was asking about session variables was to see if was needed
    WITH asp:panels, which I now assume you do not.

    But then I am still left with the original problem, whereby only the 2nd
    panel details are processed?
    I have EnableViewState set to true on both my Panels as well as the
    individual asp:textboxes (just to be sure), but this doesnt help either!

    Any light you can shine this way would be appriciated!

    Cheers
    H




    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Harry Singh, Nov 10, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. scott ocamb
    Replies:
    2
    Views:
    391
    Yan-Hong Huang[MSFT]
    Jul 30, 2003
  2. Chris Auer
    Replies:
    1
    Views:
    419
    Chris Auer
    Oct 16, 2007
  3. Eric
    Replies:
    2
    Views:
    648
  4. Michael Champagne
    Replies:
    4
    Views:
    362
    Matt Kruse
    Apr 20, 2004
  5. Joy Beeson
    Replies:
    7
    Views:
    316
    Denis McMahon
    May 29, 2013
Loading...

Share This Page