none
How to save Collected Data to a Database?

    Question

  • If I make an ASP.NET Wizard Control, how do I "tinker" with it to get it to send the data back  to me in an e-mail?
    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 5:35 PM

Answers

  • If what you are after is an email response form, one way to obtain one quickly is to use the free online generator at http://www.ctrfx.com/form/Default.aspx. There's a plethora of fields provided for, and if you want to use different names for them, look at the generated form, validation, and handler code and change their names. Do be sure to maintain any data type/format which is necessary for the field to validate (e.g., an email address field will not validate if the data it holds is not a well-formed email address, whether it is active or not).

    I haven't used this generator, but several others have and report that it does a good job (although I don't know if anyone has customized the field names as described). If you wish to roll your own, create the form and fields you wish to have and call your handler in the "action" parameter for the form. In the handler, (an aspx file if you're using ASP.NET) retrieve the fields' values using Request.Form("fieldname"). Plug them into whatever email script you're using (I like CDOSYS) and send them off.

    cheers,
    scott

    Tuesday, August 05, 2008 6:02 PM
  • Oliver Black said:

    Mailing list signup, actually. They  join the mailing list by submitting an e-mail and their name, and the data is sent to me in an e-mail.

    And also another one that collects feedback and sends an e-mail to me (and to them).

    Would what you're suggesting still apply?


    Take a chance. Prepare to be surprised.

    Oh, surely. Every field that you need for those purposes is provided in the generator. For the first form, just tick the First Name, Last Name, and Email field checkboxes on the generator page, add your email address (the one where you want results sent), and it will provide all the code necessary to implement your mailing list sign-up email form.

    On the generator page, it states

    "Generates a completely customizable form confirmation message and form error message."

    So, you can implement your feedback form the same way as the mailing list submission form, but also tick the Message checkbox so the generator includes an input area for the user to enter their feedback. Customize your confirmation message to whatever you want ("Thanks for your feedback!") and you're good to go.

    The nice thing about the generator is that you can just try it out and see what it generates, then add/delete/whatever and run it again. Give it a shot and see what you think.

    cheers,
    scott


    Tuesday, August 05, 2008 6:30 PM

All replies

  • If what you are after is an email response form, one way to obtain one quickly is to use the free online generator at http://www.ctrfx.com/form/Default.aspx. There's a plethora of fields provided for, and if you want to use different names for them, look at the generated form, validation, and handler code and change their names. Do be sure to maintain any data type/format which is necessary for the field to validate (e.g., an email address field will not validate if the data it holds is not a well-formed email address, whether it is active or not).

    I haven't used this generator, but several others have and report that it does a good job (although I don't know if anyone has customized the field names as described). If you wish to roll your own, create the form and fields you wish to have and call your handler in the "action" parameter for the form. In the handler, (an aspx file if you're using ASP.NET) retrieve the fields' values using Request.Form("fieldname"). Plug them into whatever email script you're using (I like CDOSYS) and send them off.

    cheers,
    scott

    Tuesday, August 05, 2008 6:02 PM
  • Mailing list signup, actually. They  join the mailing list by submitting an e-mail and their name, and the data is sent to me in an e-mail.

    And also another one that collects feedback and sends an e-mail to me (and to them).

    Would what you're suggesting still apply?


    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 6:19 PM More
    Tuesday, August 05, 2008 6:16 PM
  • Oliver Black said:

    Mailing list signup, actually. They  join the mailing list by submitting an e-mail and their name, and the data is sent to me in an e-mail.

    And also another one that collects feedback and sends an e-mail to me (and to them).

    Would what you're suggesting still apply?


    Take a chance. Prepare to be surprised.

    Oh, surely. Every field that you need for those purposes is provided in the generator. For the first form, just tick the First Name, Last Name, and Email field checkboxes on the generator page, add your email address (the one where you want results sent), and it will provide all the code necessary to implement your mailing list sign-up email form.

    On the generator page, it states

    "Generates a completely customizable form confirmation message and form error message."

    So, you can implement your feedback form the same way as the mailing list submission form, but also tick the Message checkbox so the generator includes an input area for the user to enter their feedback. Customize your confirmation message to whatever you want ("Thanks for your feedback!") and you're good to go.

    The nice thing about the generator is that you can just try it out and see what it generates, then add/delete/whatever and run it again. Give it a shot and see what you think.

    cheers,
    scott


    Tuesday, August 05, 2008 6:30 PM
  • That's definitely helpful (in fact, it's amazing), but I notice that it uses VB (I'd prefer C#) and ASP.NET 2.0 (not 3.5)

    When/if I become more proficient, I'd probably use EW 2's ASP.NET controls.

    Just how difficult would it be to make a form/send out with EW 2 and VS2008 Standard?

    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 6:41 PM More
    Tuesday, August 05, 2008 6:40 PM
  • Also, that form doesn't seem to have a function to send an e-mail to the person signing up.
    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 6:46 PM
  • Oliver Black said:

    Also, that form doesn't seem to have a function to send an e-mail to the person signing up.


    Take a chance. Prepare to be surprised.

    Umm, that would be the customizable confirmation email, yes?

    cheers,
    scott

    Tuesday, August 05, 2008 6:54 PM
  • Oliver Black said:

    That's definitely helpful (in fact, it's amazing), but I notice that it uses VB (I'd prefer C#) and ASP.NET 2.0 (not 3.5)

    When/if I become more proficient, I'd probably use EW 2's ASP.NET controls.

    Just how difficult would it be to make a form/send out with EW 2 and VS2008 Standard?


    Take a chance. Prepare to be surprised.

    Dunno, how hip are you to programming and debugging? In truth, VS 2008 makes many things so easy they're almost drag and drop simple. But, the more you want to customize default behaviors and provide extra capabilities, the more expectation there is that you understand both fundamental programming principles (flow control, exception handling. etc.) and the specifics of the milieu, ASP.NET framework in this case.

    cheers,
    scott

    Tuesday, August 05, 2008 6:59 PM
  • To Post #1 - yes.

    And more...

    1st, it's telling me to write my SMTP info in code view. If I put my password, username, etc., wouldn't they be visible to anyone who viewed the source code?

    I also followed the instructions listed after creating a form (including adding backend code) and when I "preview" it on my disk-based website using the Development Server, in IE7 I get this error:

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.]
    System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +2049807
    System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter writer) +49
    System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +17
    System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +17
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
    System.Web.UI.Control.Render(HtmlTextWriter writer) +7
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
    System.Web.UI.WebControls.MultiView.Render(HtmlTextWriter writer) +23
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
    System.Web.UI.Page.Render(HtmlTextWriter writer) +26
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434


    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 7:17 PM More
    Tuesday, August 05, 2008 7:09 PM
  • Oliver Black said:

    To Post #1 - yes.

    I followed the instructions listed after creating a form (including adding backend code beneath the doctype declaration) and when I "preview" it on my disk-based website, in IE7 I get this error:

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    <<::snip::>>

    First, do you get any error with the form as generated, before your modifications?

    Second, it appears that the <form runat="server"></form> container required may be missing or malformed (improperly implemented, unclosed, etc.). Either that, or the textbox control declaration was placed outside the container. Could you post the source code as you modified it (i.e. the code that throws the exception)?

    cheers,
    scott
    Tuesday, August 05, 2008 7:19 PM
  • Might be more trouble than it's worth.

    I realized I made a mistake, so I made a new form, edited the text code, and got a new error in IE7 preview:

     
    Unable to find control id 'First_Name' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'.

    Server Error in '/mysite' Application.

    Unable to find control id 'First_Name' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Unable to find control id 'First_Name' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Unable to find control id 'First_Name' referenced by the 'ControlToValidate' property of 'RequiredFieldValidator1'.]
       System.Web.UI.WebControls.BaseValidator.CheckControlValidationProperty(String name, String propertyName) +1840442
       System.Web.UI.WebControls.BaseValidator.ControlPropertiesValid() +37
       System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +33
       System.Web.UI.Control.PreRenderRecursiveInternal() +86
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Control.PreRenderRecursiveInternal() +170
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2041
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434



    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 8:05 PM
  • The forum is malfunctioning... again... it's very difficult to get the code into the page...
    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 8:07 PM
  • CODE DELETED...
    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Wednesday, August 06, 2008 4:46 PM Deleting Code
    Tuesday, August 05, 2008 8:20 PM
  • FINALLY!!!

    Here's part 2 (it wouldn't all fit)

    CODE DELETED...

    Thank you for your patience, paladun.

    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Wednesday, August 06, 2008 4:47 PM Deleting Code
    Tuesday, August 05, 2008 8:21 PM
  • OK, I think I see where this particular issue is being generated. Look at the following code block

                        <asp:TextBox ID="Name" runat="server" Columns="35"></asp:TextBox>
                    </label>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="First_Name"
                        ErrorMessage="Please enter your first name." SetFocusOnError="True" CssClass="ValidateMessage"
                        ForeColor="">* Required</asp:RequiredFieldValidator>

    If you didn't change the ID from "First_Name" to "Name," then there is an issue with the generator. The upshot is that the validator is looking for a control called "First_Name" and not finding it. I ran a find on your code and it appears that First_Name is not defined anywhere else, either. Just for giggles, modify the above so that that line of code reads

                        <asp:TextBox ID="First_Name" runat="server" Columns="35"></asp:TextBox>

    and re-run your tests. Let me know what you see.

    BTW, try to do it soon; I'll be leaving the house shortly.

    cheers,
    scott



    Tuesday, August 05, 2008 8:43 PM
  • What happened is I combined Last_Name and First_Name, so I changed that just now and a couple other things (basically modified it to just Name, since that is what the new control is)

    Now here is the error I get:

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Server Error in '/mysite' Application.

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.]
       System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +2049807
       System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter writer) +49
       System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +17
       System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +17
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
       System.Web.UI.Control.Render(HtmlTextWriter writer) +7
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.WebControls.MultiView.Render(HtmlTextWriter writer) +23
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
       System.Web.UI.Page.Render(HtmlTextWriter writer) +26
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434


    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 8:48 PM
  • Plus I have a couple HTML incompatibilities:

    HTML clipboard

    Page resources/learnmore.aspx

    Found 2 Problems

    Line 4: All <script> tags must have a type attribute.
    Line 4: In XHTML 1.0 Transitional the tag <html> cannot contain a tag <script>.


    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 8:49 PM
  • And this is the code for a blank .aspx page with a login status control

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ Page Language="C#" %>
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">
    <meta content="en-us" http-equiv="Content-Language" />
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    </head>

    <body>

    <form id="form1" runat="server">
        <asp:LoginStatus id="LoginStatus1" runat="server" />
    </form>

    </body>

    </html>


    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 8:54 PM Edit
    Tuesday, August 05, 2008 8:53 PM
  • Hopefully these problems aren't caused because I edited the controls...
    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 8:57 PM
  • Oliver Black said:

    Hopefully these problems aren't caused because I edited the controls...


    Take a chance. Prepare to be surprised.

    Well, I hate to tell you this, but I'm afraid that seems to be the case. If you don't know the language that the code is written in, VB in this case, it is very dangerous to go about modifying it without understanding the consequences of your changes. Not dangerous as in, "Oh, shyte! My computer is melting!" but dangerous as in the program blows up and throws exceptions left and right. A single misplaced token or misspelled keyword, or inappropriate change in syntax, can blow up the program

    For example, the generator presumes, and the handler is written to expect, separate fields for First Name and Last Name. If you don't know how to make the changes to concatenate those two fields into one Name field, you break the script. As you have discovered, simply changing the field name and the label doesn't get the job done.

    A suggestion: Generate the form that you want (from scratch; I'm not sure the effort of troubleshooting what you've got now is worth the time required). Test it as generated, without any modifications whatsoever. If it works (you receive the expected email), add any html/css embellishments (header, footer, sidebar, etc.) that you want, but leave anything to do with asp completely alone. Test it again. Are you beginning to see the pattern?

    It is much easier to find problems when you take one thing at a time. Then, if something breaks, you know that whatever you did last is most likely the culprit, and can zero in much more effectively in your troubleshooting. And if you version between modifications (save a copy with a numeric suffix, like default_03.aspx), then if something really blows up you can go back to your last known good page and start from there. OTOH, if you make multiple changes in one go, and things go sideways on you, you have no clue which of the many changes caused the problem, or if there is only one issue or several (as you seem to have now).

    I've gotta run now, so I won't be available for a while. But, do try the incremental process described above and see if you can't get implemented the basic functionality you're after.

    cheers,
    scott




    Tuesday, August 05, 2008 9:32 PM
  • Well, actually, I'm a newbie web designer, so I don't know any ASP.NET language too well, much less how to write them correctly.

    I did that originally, and what happened is I received that first error message.

    I redid the form and moved the backend code beneath the DWT code on top (becuase EW 2 gave an HTML incompatibility error). Unfortunately, I still have an error - <because script runat=server > on the top of that backend code must have a type attribute.

    Here's the error I get now (and this is just after inserting code):


    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Server Error in '/mysite' Application.

    Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): Control 'Email' of type 'TextBox' must be placed inside a form tag with runat=server.]
       System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +2049807
       System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter writer) +49
       System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +17
       System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +17
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
       System.Web.UI.Control.Render(HtmlTextWriter writer) +7
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.WebControls.MultiView.Render(HtmlTextWriter writer) +23
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +199
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
       System.Web.UI.Page.Render(HtmlTextWriter writer) +26
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2558
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434


    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 9:45 PM Error message
    Tuesday, August 05, 2008 9:34 PM
  • I guess you won't see this for a while, but in case anyone else can help, here's the code now:

    <%@ page language="VB" title="Untitled Page" %>  
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

        <!-- #BeginTemplate "../master.dwt" -->

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <!-- #BeginEditable "doctitle" -->
    <title>Shiloh Spiritual Center, Inc.</title>
    <style type="text/css">
    .style1 {
        font-size: medium;
    }
    </style>
    <!-- #EndEditable -->
    <link href="../styles/style1.css" media="screen" rel="stylesheet" title="CSS" type="text/css" />
    </head>

    <body>

    <!-- Begin Container -->
    <div id="container">
        <!-- Begin Masthead -->
        <div id="masthead">
            <p>
            <img alt="" height="66" src="../multimedia/Logo1.png" width="150" /></p>
            <p>
            phone (904) 471-7792<br />
            toll-free 1-877-Sheree6<br />
            e-mail info@shilohspiritualcenter.org</p>
        </div>
        <!-- End Masthead -->
        <!-- Begin Navigation -->
        <div id="navigation">
            <ul>
                <li><a href="../default.html">Home</a></li>
                <li><a href="../services/services.htm">Services</a></li>
                <li><a href="../news/news.htm">Donations</a></li>
                <li><a href="../news/news.htm">News</a></li>
                <li><a href="../products/products.htm">Products</a></li>
                <li><a href="../press/press.htm">Press</a></li>
                <li><a href="../contact/contact.htm">Resources</a></li>
            </ul>
        </div>
        <!-- End Navigation -->
        <!-- Begin Page Content -->
        <div id="page_content">
            <!-- Begin Left Column -->
            <div id="column_l">
                <!-- #BeginEditable "content" -->
               
                    <script runat="server">
            Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
                If Not Page.IsValid Then Exit Sub

                Dim SendResultsTo As String = "whor@yahoo.com"
                Dim smtpMailServer As String = "mail.yoursmtp.com"
                Dim smtpUsername As String = "yourusername"
                Dim smtpPassword As String = "yourpassword"
                Dim MailSubject As String = "Form Results"

                Try
                    Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ")
                    If txtQ IsNot Nothing Then
                        Dim ans As String = ViewState("hf1")
                        If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then
                            Me.YourForm.ActiveViewIndex = 3
                            Exit Sub
                        End If
                    End If

                    Dim FromEmail As String = SendResultsTo
                    Dim msgBody As StringBuilder = New StringBuilder()
                    Dim sendCC As Boolean = False

               
                    For Each c As Control In Me.FormContent.Controls
                        Select Case c.GetType.ToString
                            Case "System.Web.UI.WebControls.TextBox"
                                Dim txt As TextBox = CType(c, TextBox)
                                If txt.ID.ToLower <> "textboxq" Then
                                    msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf)
                                End If
                                If txt.ID.ToLower = "email" Then
                                    FromEmail = txt.Text
                                End If
                                If txt.ID.ToLower = "subject" Then
                                    MailSubject = txt.Text
                                End If
                            Case "System.Web.UI.WebControls.CheckBox"
                                Dim chk As CheckBox = CType(c, CheckBox)
                                If chk.ID.ToLower = "checkboxcc" Then
                                    If chk.Checked Then sendCC = True
                                Else
                                    msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf)
                                End If
                               
                            Case "System.Web.UI.WebControls.RadioButton"
                                Dim rad As RadioButton = CType(c, RadioButton)
                                msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf)
                            Case "System.Web.UI.WebControls.DropDownList"
                                Dim ddl As DropDownList = CType(c, DropDownList)
                                msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf)
                        End Select
                    Next
                    msgBody.AppendLine()
                   
                    msgBody.Append("Browser: " & Request.UserAgent & vbCrLf & vbCrLf)
                    msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf & vbCrLf)
                    msgBody.Append("Server Date & Time: " & DateTime.Now & vbCrLf & vbCrLf)

                    Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
                    myMessage.To.Add(SendResultsTo)
                    myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
                    myMessage.Subject = MailSubject
                    myMessage.Body = msgBody.ToString
                    myMessage.IsBodyHtml = False
                    If sendCC Then myMessage.CC.Add(FromEmail)

                   
                    Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername, smtpPassword)
                    Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer)
                    MailObj.Credentials = basicAuthenticationInfo
                    MailObj.Send(myMessage)

                    Me.YourForm.ActiveViewIndex = 1
                Catch
                    Me.YourForm.ActiveViewIndex = 2
                End Try
            End Sub

            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
                If Not Page.IsPostBack Then
                    Dim lbl As Label = Me.FormContent.FindControl("labelq")
                    If lbl IsNot Nothing Then
                        Dim rq(3) As String
                        rq(0) = "Is fire hot or cold?"
                        rq(1) = "Is ice hot or cold?"
                        rq(2) = "Is water wet or dry?"

                        Dim ra(3) As String
                        ra(0) = "hot"
                        ra(1) = "cold"
                        ra(2) = "wet"
                       
                        Dim rnd As New Random
                        Dim rn As Integer = rnd.Next(0, 3)
                        lbl.Text = rq(rn)
                        ViewState("hf1") = ra(rn)
                    End If
                End If
            End Sub
        </script>
               
                <h2>Learn More</h2>
                <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque
                ornare ipsum at erat. Quisque elementum tempus urna. Donec ornare fringilla
                erat. Phasellus gravida lectus vel dui. Fusce eget justo at odio posuere
                dignissim.</p>
                <h3>Link List Title</h3>
                <ul>
                    <li><a href="#">Hypertext Link</a><br />
                    Duis quis erat. Curabitur lobortis. Cras nunc. Aliquam erat volutpat.
                    </li>
                    <li><a href="#">Hypertext Link</a><br />
                    Cras nunc. Aliquam erat volutpat. Praesent rhoncus porttitor wisi.</li>
                    <li><a href="#">Hypertext Link</a> <br />
                    Curabitur lobortis. </li>
                </ul>
                <!-- #EndEditable --></div>
            <!-- End Left Column -->
            <!-- End Right Column --->
            <div id="column_r">
                <!-- #BeginEditable "sidebar" -->
                <h4 class="style1">Join the mailing list!</h4>
                <ul>
                    <li>            <asp:MultiView ID="YourForm" runat="server" ActiveViewIndex="0">
                <asp:View ID="FormContent" runat="server">
                            <label for="Email">
                        Enter your Email Address:<br />
                        <asp:TextBox ID="Email" runat="server" Columns="35">
                        </asp:TextBox>
                    </label>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Email"
                        Display="Dynamic" ErrorMessage="Please enter your email address." SetFocusOnError="True"
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email"
                        ErrorMessage="Please enter a valid email address." SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
                        CssClass="ValidateMessage" ForeColor="">* Please enter a valid email address.</asp:RegularExpressionValidator>
                    <br />
                    <br />
                            <label for="First_Name">
                        First Name:<br />
                        <asp:TextBox ID="First_Name" runat="server" Columns="35"></asp:TextBox>
                    </label>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="First_Name"
                        ErrorMessage="Please enter your first name." SetFocusOnError="True" CssClass="ValidateMessage"
                        ForeColor="">* Required</asp:RequiredFieldValidator>
                    <br />
                    <br />
                            <label for="Last_Name">
                        Last Name:<br />
                        <asp:TextBox ID="Last_Name" runat="server" Columns="35">
                        </asp:TextBox>
                    </label>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="Last_Name"
                        ErrorMessage="Please enter your last name." SetFocusOnError="True" CssClass="ValidateMessage"
                        ForeColor="">* Required</asp:RequiredFieldValidator>
                    <br />
                    <br />
                            <label for="TextBoxQ">
                        Anti-Spam Question:
                        <asp:Label ID="LabelQ" runat="server"></asp:Label>
                        <asp:TextBox ID="TextBoxQ" runat="server" Columns="8"></asp:TextBox>
                    </label>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="TextBoxQ"
                        Display="Dynamic" ErrorMessage="Please answer the anti-spam question." SetFocusOnError="True"
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator>
                    <br />
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                        ShowSummary="False" CssClass="ValidateMessage" ForeColor="" />
                    <br />
                    <br />
                    <asp:CheckBox ID="CheckBoxCC" runat="server" Text="Send me a carbon copy of this email." />
                    <br />
                    <br />
                    <asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click" Text="Submit Form" />
                    <br />
                </asp:View>
                <asp:View ID="FormConfirmationMessage" runat="server">
                    Your message has been sent. Thank you for contacting us.<br />
                </asp:View>
                <asp:View ID="FormErrorMessage" runat="server">
                    Due to technical difficulty, your message may NOT have been sent.
                </asp:View>
                <asp:View ID="FormSpamMessage" runat="server">
                    You did not correctly answer the anti-spam question. Please go back and try again.</asp:View>
            </asp:MultiView>
                </li>
                </ul>
                <!-- #EndEditable --></div>
            <!-- End Right Column --></div>
        <!-- End Page Content -->
        <!-- Begin Footer -->
        <div id="footer">
            <p><a href="../default.html">Home</a> |
            <a href="../contact/contact.htm">Contact</a> |
            <a href="../volunteer/volunteer.htm">Volunteer</a> |
            <a href="../faq/faq.htm">FAQ</a> |
            <a href="learnmore.aspx">Resources</a>
            | <a href="../news/news.htm">News</a> |
            <a href="../press/press.htm">Press</a> |
            <a href="../products/products.htm">Products</a>
            |
            <a href="../services/services.htm">Services</a> |
            <a href="../site_map/site_map.htm">Site Map</a></p>
            <p>Copyright © 2008 Shiloh Spiritual Center, Inc. All Rights Reserved.</p>
        </div>
        <!-- End Footer --></div>
    <!-- End Container -->

    </body>

    <!-- #EndTemplate -->

    </html>

    UPDATE: I added type="VB" inside the scriprt runat thing I was talking about and that got rid of the HTML incompatibility error (but not the one I get in IE7). So now it reads: <script runat="server" type="VB">

    If it's a mistake, I can easily change it back...

    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Tuesday, August 05, 2008 9:57 PM More
    Tuesday, August 05, 2008 9:47 PM
  • OK, back for a bit before heading out for a meeting tonight. After reading your comment at the head of the last message and scanning your pasted source, I believe that I know your problem. This code is designed to be used within an aspx page, and must be placed within the form tags which exist in any such page. If you had read the instructions for using the script, provided on the generator page, you would have found this:

    "Insert the following code where you wish the form to appear on your ASP.NET page. Be sure to place it somewhere within the <form runat="server">  tag or within a <asp:content>  tag if your page is attached to a Master Page."

    After reading your opening comment, I realized that you were working with a DWT and not an aspx page. Searching your posted code revealed that, sure enough, there was no form container for the script, which is why you are getting the error that you are now seeing.

    Tell you what, I'm going to revise my suggestion that you use that generator and instead suggest that you avail yourself of Jim Cheshire's three-part tutorial on building an email response form and confirmation email, available here http://www.jimcobooks.com/tutorials/. Since you have acknowledged your relative rookie status, I believe that going through these tutorials would teach you a good deal of valuable knowledge that will stand you in good stead in the future. Furthermore, you will understand the structure of the page much more clearly and, I believe, be able to successfully make the necessary modifications to fit your look and feel when you've finished building the form.

    cheers,
    scott

    Tuesday, August 05, 2008 10:42 PM
  • paladun said:



    "Insert the following code where you wish the form to appear on your ASP.NET page. Be sure to place it somewhere within the <form runat="server">  tag or within a <asp:content>  tag if your page is attached to a Master Page."




    Yeah, I saw that - but like you said, it's only for a Master Page.

    Notice that it says "if." That means that it doesn't have to be in a Master Page, so there should be some way to make it work with a DWT.

    And you revise your suggestion after I've mark it as helpful? Hmph (I'd mark this new post as helpful but I think one is enough for you this time)

    Anyone else have advice? How about similar tutorials?

    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 11:16 PM
  • Oliver Black said:

    paladun said:

    "Insert the following code where you wish the form to appear on your ASP.NET page. Be sure to place it somewhere within the <form runat="server">  tag or within a <asp:content>  tag if your page is attached to a Master Page."

    Yeah, I saw that - but like you said, it's only for a Master Page.


    Notice that it says "if." That means that it doesn't have to be in a Master Page, so there should be some way to make it work with a DWT.

    And you revise your suggestion after I've mark it as helpful? Hmph (I'd mark this new post as helpful but I think one is enough for you this time)

    Anyone else have advice? How about similar tutorials?

    Take a chance. Prepare to be surprised.

    No, you are mistaking the meaning of that sentence. The code can be placed into a standard aspx page, in which case you place it within the <form> tags, or it can be placed into a content page linked to a master page, in which case you place it within the <asp:content> tags. So, no, it doesn't have to be a master page, but it must be an ASP.NET page, whether standalone or the asp content portion of a linked page. A DWT template page, AFAIK, will not be recognized as processable by the server, and does not contain the necessary runat="server" instruction.

    Well, Oliver, I thought it best to revise what I had suggested after discovering, through the course of this discussion, a bit more about where you currently are in the learning process. Most intermediate-level developers would be able to implement that generated form without a whole lot of difficulty. No offense was intended. Hell, I'm a Microsoft Certified Professional and have been coding since the seventies, and writing html since the nineties, and I watched those Cheshire tutorials to learn more about EW development practices.

    Anyway, do check them out, and follow along with them. They can't hurt, and may just teach you something valuable.

    cheers,
    scott


    Tuesday, August 05, 2008 11:33 PM
  • Well, okay, Scott... I'm assuming that if I wanted to use the generator with the .aspx and DWT, I couldn't just add the code neccesary for the runat=server?
    Take a chance. Prepare to be surprised.
    Tuesday, August 05, 2008 11:38 PM
  • Oliver Black said:

    Well, okay, Scott... I'm assuming that if I wanted to use the generator with the .aspx and DWT, I couldn't just add the code neccesary for the runat=server?


    Take a chance. Prepare to be surprised.

    Just got back in...

    What the hell; if you want to give it a shot, you could always try adding a <form name="form1" runat="server"> immediately following the opening <body> tag, and a </form> immediately preceding the closing </body> tag. Since I don't use DWTs, I'd be curious to find out what you learn. I don't think it will work without the aspx extension [according to Kevin the ASP request processor will not be invoked], but if you want to try it will only cost you your time.

    Frankly, I would just use an ASP.NET master page and be done with it. Those even offer the advantage of explicitly supporting nested master pages, which is dodgy at best when dealing with DWTs, and they have all of the capabilities of DWTs in terms of providing standard look and feel while shielding non-editable regions. The only disadvantage I can see is that they require support for ASP.NET on the server, which to me is not a disadvantage since I prefer Windows servers anyway.

    cheers,
    scott


    • Edited by paladyn Wednesday, August 06, 2008 2:30 AM ....
    Wednesday, August 06, 2008 2:06 AM
  • I was using a .aspx extension for that page. I switched it following instructions in that thread I created.
    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 4:14 PM
  • OK, sounds good. So, did you try the suggestion of adding the necessary <form runat="server> tags I described in my previous message (they should go just inside the <body> tags)? Did it work? What did you see?

    cheers,
    scott

    Wednesday, August 06, 2008 4:50 PM
  • I didn't try that becuase I deleted the inserted control after you told me to.

    Maybe sometime I'll fire up the generator again and do that, but I'm not going to be around today...

    (I'll post if I do)





    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 4:53 PM
  • Error:


    Compilation Error

    Server Error in '/mysite' Application.

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30035: Syntax error.

    Source Error:

    Line 56:         Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Line 57:             If Not Page.IsValid Then Exit Sub
    Line 58: =
    Line 59:             Dim SendResultsTo As String = "whor@yahoo.com"
    Line 60:             Dim smtpMailServer As String = "mail.yoursmtp.com"

    Source File: C:\Users\Silver\Documents\My Web Sites\mysite\resources\learnmore.aspx    Line: 58





    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434

    Okay... I recopied the code from my last post and am testing...
    Take a chance. Prepare to be surprised.




    • Edited by Oliver Black Wednesday, August 06, 2008 5:12 PM Error message
    Wednesday, August 06, 2008 4:56 PM


  • After also providing a type for script runat I got this new error:

     Parser Error

    Server Error in '/mysite' Application.

    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: The server tag is not well formed.

    Source Error:

    Line 53:             <!-- #BeginEditable "content" -->
    Line 54:            
    Line 55:                 <script runat="server"type="text/vbscript">
    Line 56:         Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Line 57:             If Not Page.IsValid Then Exit Sub

    Source File: /mysite/resources/learnmore.aspx    Line: 55


    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434






    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 5:11 PM
  • I think I got that script part written wrong...
    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 5:15 PM
  • Oliver Black said:

    I think I got that script part written wrong...


    Take a chance. Prepare to be surprised.

    According to the instructions provided at the generator site, there is no need to modify the script tag. I don't know if it's the source of the error, but there is no space between the runat and the type. Did you add <form runat="server"> after the <body> tag, and </form> before the closing </body> tag, as suggested?

    Have you tried simply creating a new aspx page using EW's menu and then pasting the generator code into it between the form tags?

    cheers,
    scott


    Wednesday, August 06, 2008 5:40 PM
  • Okay - here's what happened. I inserted the code you mentioned (which unfortunately found itself in the DWT part of the page), and noticed that I had an HTML incompatibility somewhere else on the page (it said <script runat="server"> needed a type attribute).

    I ignored it and got the first error I posted (out of the last two).

    Then I changed it to <script runat="server"type="text/vb">

    It got rid of the incompatibility warning, but then I got the second error, making me assume that I have it written wrong (though how I'm not exactly sure)

    You do have knowledge of ASP.NET, right? Ideas?



    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 6:08 PM
  • I Googled that code and someone had it written like:

    <script type="text/VBScript" runat="server">

    I edited VBScript to vb, and that still kept the HTML incompatibility away. But I get an error like the first out of the two I mentioned:

    Compilation Error

    Server Error in '/mysite' Application.

    Compilation Error

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30035: Syntax error.

    Source Error:

    Line 56:         Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Line 57:             If Not Page.IsValid Then Exit Sub
    Line 58: =
    Line 59:             Dim SendResultsTo As String = "whor@yahoo.com"
    Line 60:             Dim smtpMailServer As String = "mail.yoursmtp.com"

    Source File: C:\Users\Silver\Documents\My Web Sites\mysite\resources\learnmore.aspx    Line: 58





    Version Information: Microsoft .NET Framework Version:2.0.50727.1434; ASP.NET Version:2.0.50727.1434


    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 6:18 PM
  • Here's what Firefox 3 is telling me:

    XML Parsing Error: not well-formed
    Location: file:///C:/Users/Silver/Documents/My%20Web%20Sites/mysite/resources/learnmore.aspx
    Line Number 1, Column 2:<%@ page language="VB" title="Untitled Page" %> 
    -^

    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 7:17 PM
  • Don't edit the bloody code!

    After all this, I generated a form at the same site, pasted it into a blank master page in VWD, and it worked like a champ. There_is_nothing_wrong_with_the_code!

    Sorry, but I have suggested what you need to try, and explained that you should not edit the code without knowing what the consequences will be, and you continue to blithely ignore my suggestions and try to salvage this mess of a hybrid DWT/aspx page by messing with the code. It is NOT broken--or wasn't--so don't muck about with it.

    OK, here's what I suggest: File|New|ASPX. When the page opens, check the Page directive to make sure that the language is set to VB (this generator only creates VB code). Now, look down after the <head> section. You should see something like this

    <body>
        <form id="form1" runat="server">
        <div>

        </div>
        </form>
    </body>

    Use a pristine, untouched, unedited, unchanged copy of the form code from the generator (the part within the Multiview tags), and follow explicitly the instructions given at the site for its use to paste the code into the form. Since the form element will initially be empty save for the container div, just paste between the supplied div tags. There's your form. At this point you should be able to view it and see the form laid out. It won't do anything yet, because the handler script isn't available.

    Now, because my EW trial has expired, I'm working in VWD, but this should be the same or similar for you. You have the option to either paste the script code within the same div used for the form code, or to paste it between the doctype and the opening <html> tag. I have tested it both ways, and it works both ways. Below my sig you will see the entire page code for the currently working page on my machine. Since the last version I tested had the script code above the <html> element, that's the version you will see. If you copy it whole cloth and replace the entire contents of the aspx page you created above with it, it will test good.

    To test the email functionality, of course, you will need to follow the directions to modify the generated email server, your email address, etc. But, it will display correctly, and if you properly customize it with the necessary server and address information, it will work.

    scott
    [Sample Page Source Follows]
    <%@ Page Language="VB" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <script runat="server"
        Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
            If Not Page.IsValid Then Exit Sub 
     
            Dim SendResultsTo As String = "mymail@fuse.net" 
            Dim smtpMailServer As String = "mail.yoursmtp.com" 
            Dim smtpUsername As String = "yourusername" 
            Dim smtpPassword As String = "yourpassword" 
            Dim MailSubject As String = "Form Results" 
     
            Try 
                Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ") 
                If txtQ IsNot Nothing Then 
                    Dim ans As String = ViewState("hf1") 
                    If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then 
                        Me.YourForm.ActiveViewIndex = 3 
                        Exit Sub 
                    End If 
                End If 
     
                Dim FromEmail As String = SendResultsTo 
                Dim msgBody As StringBuilder = New StringBuilder() 
                Dim sendCC As Boolean = False 
     
                 
                For Each c As Control In Me.FormContent.Controls 
                    Select Case c.GetType.ToString 
                        Case "System.Web.UI.WebControls.TextBox" 
                            Dim txt As TextBox = CType(c, TextBox) 
                            If txt.ID.ToLower <> "textboxq" Then 
                                msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf) 
                            End If 
                            If txt.ID.ToLower = "email" Then 
                                FromEmail = txt.Text 
                            End If 
                            If txt.ID.ToLower = "subject" Then 
                                MailSubject = txt.Text 
                            End If 
                        Case "System.Web.UI.WebControls.CheckBox" 
                            Dim chk As CheckBox = CType(c, CheckBox) 
                            If chk.ID.ToLower = "checkboxcc" Then 
                                If chk.Checked Then sendCC = True 
                            Else 
                                msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf) 
                            End If 
                                 
                        Case "System.Web.UI.WebControls.RadioButton" 
                            Dim rad As RadioButton = CType(c, RadioButton) 
                            msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf) 
                        Case "System.Web.UI.WebControls.DropDownList" 
                            Dim ddl As DropDownList = CType(c, DropDownList) 
                            msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf) 
                    End Select 
                Next 
                msgBody.AppendLine() 
                     
                msgBody.Append("Browser: " & Request.UserAgent & vbCrLf & vbCrLf) 
                msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf & vbCrLf) 
                msgBody.Append("Server Date & Time: " & DateTime.Now & vbCrLf & vbCrLf) 
     
                Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() 
                myMessage.To.Add(SendResultsTo) 
                myMessage.From = New System.Net.Mail.MailAddress(FromEmail) 
                myMessage.Subject = MailSubject 
                myMessage.Body = msgBody.ToString 
                myMessage.IsBodyHtml = False 
                If sendCC Then myMessage.CC.Add(FromEmail) 
     
                     
                Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername, smtpPassword) 
                Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer) 
                MailObj.Credentials = basicAuthenticationInfo 
                MailObj.Send(myMessage) 
     
                Me.YourForm.ActiveViewIndex = 1 
            Catch 
                Me.YourForm.ActiveViewIndex = 2 
            End Try 
        End Sub 
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
            If Not Page.IsPostBack Then 
                Dim lbl As Label = Me.FormContent.FindControl("labelq") 
                If lbl IsNot Nothing Then 
                    Dim rq(3) As String 
                    rq(0) = "Is fire hot or cold?" 
                    rq(1) = "Is ice hot or cold?" 
                    rq(2) = "Is water wet or dry?" 
     
                    Dim ra(3) As String 
                    ra(0) = "hot" 
                    ra(1) = "cold" 
                    ra(2) = "wet" 
                         
                    Dim rnd As New Random 
                    Dim rn As Integer = rnd.Next(0, 3) 
                    lbl.Text = rq(rn) 
                    ViewState("hf1") = ra(rn) 
                End If 
            End If 
        End Sub 
    </script> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server"
        <div> 
        <%--    Form code  --%> 
                    <asp:MultiView ID="YourForm" runat="server" ActiveViewIndex="0"
                <asp:View ID="FormContent" runat="server"
                            <label for="Email"
                        Enter your Email Address:<br /> 
                        <asp:TextBox ID="Email" runat="server" Columns="35"
                        </asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Email" 
                        Display="Dynamic" ErrorMessage="Please enter your email address." SetFocusOnError="True" 
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email" 
                        ErrorMessage="Please enter a valid email address." SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                        CssClass="ValidateMessage" ForeColor="">* Please enter a valid email address.</asp:RegularExpressionValidator> 
                    <br /> 
                    <br /> 
                            <label for="Message"
                        Please type your message below: 
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Message" 
                            ErrorMessage="Please enter a message" SetFocusOnError="True" CssClass="ValidateMessage" 
                            ForeColor="">* Required</asp:RequiredFieldValidator> 
                        <br /> 
                        <asp:TextBox ID="Message" runat="server" TextMode="MultiLine" Columns="55" Rows="10"
                        </asp:TextBox> 
                    </label> 
                    <br /> 
                    <br /> 
                            <label for="First_Name"
                        First Name:<br /> 
                        <asp:TextBox ID="First_Name" runat="server" Columns="35"></asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="First_Name" 
                        ErrorMessage="Please enter your first name." SetFocusOnError="True" CssClass="ValidateMessage" 
                        ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <br /> 
                    <br /> 
                            <label for="Last_Name"
                        Last Name:<br /> 
                        <asp:TextBox ID="Last_Name" runat="server" Columns="35"
                        </asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="Last_Name" 
                        ErrorMessage="Please enter your last name." SetFocusOnError="True" CssClass="ValidateMessage" 
                        ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <br /> 
                    <br /> 
                            <label for="TextBoxQ"
                        Anti-Spam Question: 
                        <asp:Label ID="LabelQ" runat="server"></asp:Label> 
                        <asp:TextBox ID="TextBoxQ" runat="server" Columns="8"></asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="TextBoxQ" 
                        Display="Dynamic" ErrorMessage="Please answer the anti-spam question." SetFocusOnError="True" 
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <br /> 
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" 
                        ShowSummary="False" CssClass="ValidateMessage" ForeColor="" /> 
                    <br /> 
                    <br /> 
                    <asp:CheckBox ID="CheckBoxCC" runat="server" Text="Send me a carbon copy of this email." /> 
                    <br /> 
                    <br /> 
                    <asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click" Text="Submit Form" /> 
                    <br /> 
                </asp:View> 
                <asp:View ID="FormConfirmationMessage" runat="server"
                    Your message has been sent. Thank you for contacting us.<br /> 
                </asp:View> 
                <asp:View ID="FormErrorMessage" runat="server"
                    Due to technical difficulty, your message may NOT have been sent. 
                </asp:View> 
                <asp:View ID="FormSpamMessage" runat="server"
                    You did not correctly answer the anti-spam question. Please go back and try again.</asp:View> 
            </asp:MultiView> 
         
        </div> 
        </form> 
    </body> 
    </html> 
     





    Wednesday, August 06, 2008 7:27 PM
  • I was editing the code because I was getting HTML incompatibilities.

    Just a reminder: I am using a .aspx page that is based on a DWT, not a master page.

    And this is not a blank page I'm putting it on, either.

    Am following your latest suggestions...

    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 7:34 PM
  • Though like I said, I have to fit it inside the DWT...
    Take a chance. Prepare to be surprised.
    Wednesday, August 06, 2008 7:35 PM
  • Oliver Black said:

    Though like I said, I have to fit it inside the DWT...


    Take a chance. Prepare to be surprised.

    I give up.

    Find someone else to ignore.

    I quit.

    scott

    Wednesday, August 06, 2008 7:39 PM
  • Okay, okay... I'm really sorry, paladun. I didn't read your entire post.

    <script runat="server"

    But this above line (immediately following the doctype declaration) is creating two incompatibilites that EW 2 is flagging:

    First, EW 2 says it needs a type attribute.

    And second, it says the <script> tag must be included inside a parent tag.

    Can you please help me just a little bit more?





















    Take a chance. Prepare to be surprised.
    Thursday, August 07, 2008 10:55 PM
  • Oh! And the form works with your advice.
    Take a chance. Prepare to be surprised.
    Thursday, August 07, 2008 10:56 PM
  • please?
    Sunday, August 10, 2008 1:53 AM
  • SUMMARY:

    The original question was how I could make a form using the controls/tutorial for EW 2. Scott (paladun) suggested http://www.ctrfx.com/form/Default.aspx instead, so I went with that (since I am - honestly - little more than a newbie at web design/programming).

    Unfortunately, I had a lot of difficulty "fitting" it inside an ASP.NET page with a DWT without errors - and Scott stopped following this thread after I didn't read all of his last post.

    I figured it out - and it works! With two errors: one is that script runat must have a type attribute and also that it must be included inside a parent tag.

    So now we continue to what happened after...

    UPDATES:

    Following advice from this link: http://www.directorforum.de/showthread.php?t=73942

    I discovered that the two errors I was receiving were because EW 2 doesn't recognize server-side code so well.

    But I did change <script runat = server> to:  <script type="text/vb" runat="server">

    I've modified the code somewhat. Before I had "First_Name" and using find and replace renamed the control to "Name" then I changed the order of the e-mail and name controls.

    Afterward, I made an external style sheet with this: <link href="../styles/validatemessage.css" rel="stylesheet" type="text/css" /> and attached it to the page.

    Note that the form still appears to be fully functional (so I don't think I broke anything).

    Now I want to remove the control that says "send me a carbon copy." In a seperate thread, he said just deleting the control would be fine, but I thought I'd paste the code so he can double-check there isn't anything else in the backend code that references it.

    Then, I was wondering how I could update the code for ASP.NET 3.5 (as the control is using 2.0)

    This form (with different fields) is going to be used on several pages, so hopefully I can keep your advice generic enough...

    (And please let me know if the methods I followed were wrong, or if you have a better way for form creation with ASP.NET, preferably with the language I want to start learning, C#)



    Take a chance. Prepare to be surprised.
    Friday, August 15, 2008 4:32 PM
  • <%@ Page Language="VB" %>  
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
        <script type="text/vb" runat="server"
            Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
                If Not Page.IsValid Then Exit Sub 
     
                Dim SendResultsTo As String = "soandsoandso" 
                Dim smtpMailServer As String = "mail.personal.com" 
                Dim smtpUsername As String = "info@mysite.com" 
                Dim smtpPassword As String = "*******" 
                Dim MailSubject As String = "Form Results" 
     
                Try 
                    Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ") 
                    If txtQ IsNot Nothing Then 
                        Dim ans As String = ViewState("hf1") 
                        If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then 
                            Me.YourForm.ActiveViewIndex = 3 
                            Exit Sub 
                        End If 
                    End If 
     
                    Dim FromEmail As String = SendResultsTo 
                    Dim msgBody As StringBuilder = New StringBuilder() 
                    Dim sendCC As Boolean = False 
     
                 
                    For Each c As Control In Me.FormContent.Controls 
                        Select Case c.GetType.ToString 
                            Case "System.Web.UI.WebControls.TextBox" 
                                Dim txt As TextBox = CType(c, TextBox) 
                                If txt.ID.ToLower <> "textboxq" Then 
                                    msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf) 
                                End If 
                                If txt.ID.ToLower = "email" Then 
                                    FromEmail = txt.Text 
                                End If 
                                If txt.ID.ToLower = "subject" Then 
                                    MailSubject = txt.Text 
                                End If 
                            Case "System.Web.UI.WebControls.CheckBox" 
                                Dim chk As CheckBox = CType(c, CheckBox) 
                                If chk.ID.ToLower = "checkboxcc" Then 
                                    If chk.Checked Then sendCC = True 
                                Else 
                                    msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf) 
                                End If 
                                 
                            Case "System.Web.UI.WebControls.RadioButton" 
                                Dim rad As RadioButton = CType(c, RadioButton) 
                                msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf) 
                            Case "System.Web.UI.WebControls.DropDownList" 
                                Dim ddl As DropDownList = CType(c, DropDownList) 
                                msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf) 
                        End Select 
                    Next 
                    msgBody.AppendLine() 
                     
                    msgBody.Append("Browser: " & Request.UserAgent & vbCrLf & vbCrLf) 
                    msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf & vbCrLf) 
                    msgBody.Append("Server Date & Time: " & DateTime.Now & vbCrLf & vbCrLf) 
     
                    Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() 
                    myMessage.To.Add(SendResultsTo) 
                    myMessage.From = New System.Net.Mail.MailAddress(FromEmail) 
                    myMessage.Subject = MailSubject 
                    myMessage.Body = msgBody.ToString 
                    myMessage.IsBodyHtml = False 
                    If sendCC Then myMessage.CC.Add(FromEmail) 
     
                     
                    Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername, smtpPassword) 
                    Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer) 
                    MailObj.Credentials = basicAuthenticationInfo 
                    MailObj.Send(myMessage) 
     
                    Me.YourForm.ActiveViewIndex = 1 
                Catch 
                    Me.YourForm.ActiveViewIndex = 2 
                End Try 
            End Sub 
     
            Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) 
                If Not Page.IsPostBack Then 
                    Dim lbl As Label = Me.FormContent.FindControl("labelq") 
                    If lbl IsNot Nothing Then 
                        Dim rq(3) As String 
                        rq(0) = "Is fire hot or cold?" 
                        rq(1) = "Is ice hot or cold?" 
                        rq(2) = "Is water wet or dry?" 
     
                        Dim ra(3) As String 
                        ra(0) = "hot" 
                        ra(1) = "cold" 
                        ra(2) = "wet" 
                         
                        Dim rnd As New Random 
                        Dim rn As Integer = rnd.Next(0, 3) 
                        lbl.Text = rq(rn) 
                        ViewState("hf1") = ra(rn) 
                    End If 
                End If 
            End Sub 
        </script> 
     
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml"
     
    <!-- #BeginTemplate "../master.dwt" --> 
     
    <head> 
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> 
    <!-- #BeginEditable "doctitle" --> 
    <title>Untitled 1</title> 
    <style type="text/css"
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    .style1 { 
        font-size: medium; 
    </style> 
    <link href="../styles/validatemessage.css" rel="stylesheet" type="text/css" /> 
    <!-- #EndEditable --> 
    <link href="../styles/style1.css" media="screen" rel="stylesheet" title="CSS" type="text/css" /> 
    </head> 
     
    <body> 
     
    <!-- Begin Container --> 
    <div id="container"
        <!-- Begin Masthead --> 
        <div id="masthead"
            <p> 
            <img alt="" height="66" src="../multimedia/Logo1.png" width="150" /></p
            <p> 
            phone personal<br /> 
            toll-free personal<br /> 
            e-mail personal</p> 
        </div> 
        <!-- End Masthead --> 
        <!-- Begin Navigation --> 
        <div id="navigation"
            <ul> 
                <li><a href="../default.html">Home</a></li
                <li><a href="../services/services.htm">Services</a></li
                <li><a href="../donations/donate.htm">Donations</a></li
                <li><a href="../news/news.htm">News</a></li
                <li><a href="../products/products.htm">Products</a></li
                <li><a href="../press/press.htm">Press</a></li
                <li><a href="learnmoreold.aspx">Resources</a></li
            </ul> 
        </div> 
        <!-- End Navigation --> 
        <!-- Begin Page Content --> 
        <div id="page_content"
            <!-- Begin Left Column --> 
            <div id="column_l"
                <!-- #BeginEditable "content" --> 
                <h2>Headline 2</h2> 
                <p>insert content here</p> 
                <!-- #EndEditable --></div
            <!-- End Left Column --> 
            <!-- End Right Column --> 
            <div id="column_r"
                <!-- #BeginEditable "sidebar" --> 
                <h3 class="style1">Join our Mailing list!</h3> 
                <form id="form1" runat="server">  
        <div>  
        <%--    Form code  --%>  
                <asp:MultiView ID="YourForm" runat="server" ActiveViewIndex="0"
                <asp:View ID="FormContent" runat="server"
                            <label for="Name"
                            Enter your Full Name:<br /> 
                        <asp:TextBox ID="Name" runat="server" Columns="35" Width="185px"></asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Name" 
                        ErrorMessage="Please enter your full name." SetFocusOnError="True" CssClass="ValidateMessage" 
                        ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <br /> 
                    <br /> 
                    <label for="Email"
                            Email Address:<br /> 
                        <asp:TextBox ID="Email" runat="server" Columns="35" Width="185px"></asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Email" 
                        Display="Dynamic" ErrorMessage="Please enter your email address." SetFocusOnError="True" 
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email" 
                        ErrorMessage="Please enter a valid email address." SetFocusOnError="True" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                        CssClass="ValidateMessage" ForeColor="">* Please enter a valid email address.</asp:RegularExpressionValidator> 
                    <br /> 
                    <br /> 
                            <label for="TextBoxQ"
                        Anti-Spam Question: 
                        <asp:Label ID="LabelQ" runat="server"></asp:Label> 
                        <asp:TextBox ID="TextBoxQ" runat="server" Columns="8"></asp:TextBox> 
                    </label> 
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ControlToValidate="TextBoxQ" 
                        Display="Dynamic" ErrorMessage="Please answer the anti-spam question." SetFocusOnError="True" 
                        CssClass="ValidateMessage" ForeColor="">* Required</asp:RequiredFieldValidator> 
                    <br /> 
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" 
                        ShowSummary="False" CssClass="ValidateMessage" ForeColor="" /> 
                    <br /> 
                    <br /> 
                    <asp:CheckBox ID="CheckBoxCC" runat="server" Text="Send me a copy of the information sent." /> 
                    <br /> 
                    <br /> 
                    <asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click" Text="Submit Form" /> 
                    <br /> 
                </asp:View> 
                <asp:View ID="FormConfirmationMessage" runat="server"
                    Your message has been delivered. Thank you for contacting us.<br /> 
                </asp:View> 
                <asp:View ID="FormErrorMessage" runat="server"
                    Due to technical difficulty, your message may NOT have been  
                    sent. Please contact the 
                    <href="mailto:webmaster@shilohspiritualcenter.org?subject=Form Problem"
                    webmaster</a>
                </asp:View> 
                <asp:View ID="FormSpamMessage" runat="server"
                    You did not correctly answer the anti-spam question. Please go back and try again.</asp:View> 
            </asp:MultiView> 
              </div>  
        </form>  
     


    Take a chance. Prepare to be surprised.
    • Edited by Oliver Black Friday, August 15, 2008 4:35 PM edit
    Friday, August 15, 2008 4:34 PM
  • Interestingly enough, VS2008 Standard is telling me that the site is using the .NET Framework 2.0, so I told it to update it (Though I'm not saving changes yet)



    Take a chance. Prepare to be surprised.
    Friday, August 15, 2008 4:41 PM
  • Actually, I think it saved automatically... hm...
    Take a chance. Prepare to be surprised.
    Friday, August 15, 2008 4:44 PM