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...
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); }
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.
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:
And in the code-behind:
Hope that helps,
Sascha
Buy contour for 99$ and you can create forms as much as you like, with validation, notification and other actions ;)
Thanks for your replies
is working on a reply...