Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kasper Dyrvig 246 posts 379 karma points
    Aug 13, 2010 @ 11:31
    Kasper Dyrvig
    0

    How do I create a "Contact me" form?

    I want a page with a contact form. The user must type Name, email, topic and a message. Then he click "Send" and then I get an email with the information.

    But so far I haven't made it work. But I am sure that some of you have something I can use...

    Thank you.

  • Sascha Wolter 615 posts 1101 karma points
    Aug 13, 2010 @ 12:20
    Sascha Wolter
    0

    Hi Webspas,

    I would probably create a .Net control that contains the functionality and place it in the template. The following is very simple, you would definitely need some kind of validation, style it up etc:

            <p>
                Please fill out the form below to contact us.
            </p>
            <table>
                <tr>
                    <td>Name:</td>
                    <td><asp:TextBox runat="server" ID="Name" /></td>
                </tr>
                <tr>
                    <td>Email:</td>
                    <td><asp:TextBox runat="server" ID="Email" /></td>
                </tr>
                <tr>
                    <td>Message: </td>
                    <td><asp:TextBox runat="server" ID="Message" TextMode="MultiLine" Rows="5" /></td>
                </tr>
                <tr>
                    <td></td>
                    <td><asp:Button runat="server" ID="btnSubmit" Text="Submit"
                            onclick="btnSubmit_Click" /></td>
                </tr>
            </table>

    And in the code-behind:

            protected void btnSubmit_Click(object sender, EventArgs e)
            {
                //validate the input!!
                MailMessage mm = new MailMessage
                                     {
                                         From = new MailAddress("[email protected]"),
                                         Body =
                                             String.Format(
                                                 "Somebody has just left a message on the website: \nName: {0}\nEmail: {1}\nMessage: {2}",
                                                 Name.Text, Email.Text, Message.Text)
                                     };
                mm.To.Add(new MailAddress("[email protected]"));
                SmtpClient client = new SmtpClient();
                //you might need to configure your host here
                client.Send(mm);
            }

    Hope that helps,
    Sascha

     

  • Rik Helsen 670 posts 873 karma points
    Aug 13, 2010 @ 14:39
    Rik Helsen
    0

    Buy contour for 99$ and you can create forms as much as you like, with validation, notification and other actions ;)

  • Kasper Dyrvig 246 posts 379 karma points
    Aug 13, 2010 @ 15:11
    Kasper Dyrvig
    0

    Thanks for your replies

Please Sign in or register to post replies

Write your reply to:

Draft