WorldofASP.NET : ASP.NET Tutorial, Hosting, and Source Code
You are 1 of 6778 users

WorldofASP.NET >> ASPNET >> Unedited ASPNET

Simple asp2 feedback form

A simple way to get user feedback via webpage email.

Published Date : 21 Feb 2008

Author : kane nelson
Language : VB.NET
Platform : Wins,.NET
 
Technology : Visual Studio,ASP.NET
Views : 1378
Rating : (1 votes so far)
Email to a Friend | Print this Article | Add to Favourites | Report Error

Introduction

Hi everyone, im not a professional developer by far.... but for many years when I began I struggled to find good tutorials for me as a beginner. All were alot more advanced & refered to items & means I had NO idea of at all which then made trying to teach yourself impossible!!.

I wanted Just simple straight to the point and the type that explained JUST what i needed to know to
progress, nothing more Nor less.

In this article I will show the beginners out there how to make a feedback form, that sends you the
contents in an email simply, using the System.net.mail Or i use System.web.mail namespace.
This can easily be developed on and hopefully helps a lot of the new comers to progression in mailing
 from web pages. 

Note this feedback form will only run on host's that are asp/2 compatible (windows) servers.

Main

Step 1:
Lets start by making a simple aspx page through visual studio, call it "Feedback.aspx" & don't add a
 code behind page (no use here we'll script it in YAY!). Now the 1st couple of lines of our page should
read as below, if not change it to so.



Note: you'll see we add the session state to false so we dont get our form holding data, and i
always like to import our namespaces so do like above.

Also add Or make sure your document type & declarations are like below as its a good practice to get
into when creating W3C webpages by standards XHTML Strict is a must!.



Step 2:

the <body> of our document if it's an aspx page will already have a <form> element if not add one,
inside this lets add our feedback form controls i always use a table to keep things neat ... as code
below:

Pay particular attention to our submit button, the onclick : onserverclick="btn_Click()" we'll add
this code a little later.

Here's an image of how the layout should look Or you can dizzy it up to your own style & like:


Yay we're off and running, there's nothing in that block of code you really need pay attention to. All we
have really done if your looking at your page in design mode is add a table with 5 new controls ; Name,
 email, subject, message & submit
.These will be our email message area's, lets move on.

Step 3:
Just below our table lets add our label for the response once the feedback is submitted. Do so as
below, note i add the label text in Orange for effect of catching attention after a submission.



Now for the fun part lets get cracking at putting our coding skills to good use, Right back up the top of
 our page, somewhere above the <head> element lets setup our functions & mail object.

Step 4:
First of all we'll add our <script> tags as so and be sure to specify language type:


then we add our page load function like so on the very next line, you'll notice the page load specifies if our page is a postback then set the label response to what ever we want to say once the email is sent Or else the user needs to fill in the email feild of our form.


Step 5:
Now last but not least our button click Or submit form. Let's go through the below code, if our request forms email field = to nothing then create new message, add from text, to text (Note: this will be your email address that you want to receive email on), subject from our drop down list, emailbody from our text area Or note i've also added some HTML, along with the users name and attached both via " code here" & " code here" statements, next is  body format (Note: you can set this to what ever you like), smtp server (Note: this will be your email hosting server address to send emails) & finally our mail object name we created at the IF statement at our button click beginning.



Conclusion

And that My friends is just about it your page can now be uploaded to your ASP(windows) host and
send you form feedback to no end ! *smile* . I hope many of you enjoyed this and as you can see with
 a little tinkering it could easily be added to, such as a user control for sending personal emails to
others, Or also  add a fileupload control for email attachments.



Other Related and Popular Articles :

Building a Site Navigation and Site Menu Using ASP.NET Sitemap and SitemapDataSource Control
How to build sitemap and navigate a site in asp.net
Designing a Membership Sign-Up and Login Page in ASP.NET
How to design user interface for registration and login in ASP.NET
Validate Email and Domain in a Web Form
Simple method to validate using javascript and ASP.NET validation control
Basics of XHTML-MP
Basics of XHTML-MP
Activate User Registration by Email in ASP.NET
How to activate registered user using System.Net.Mail.SMTPClient class

Author Profile : kane nelson

Self paced learner i have been teaching myself ASP 2, .NET, AJAX, JAVASCRIPT & WEB DESIGN for 5+ years now. Based in australia i am now working for the Victorian government as a software developer, system support officer and tech support analyst.
BORN Jan 1st 1974 im 33 years young and love working on a range of applications and many programming languages, developer of MANY and a MASTER of NONE !! hahaha *smiles*

*He whom thinks he has mastered all, is only a mastered man ! *

Click here to view Author Profile


How would you rate the quality of this content?
Poor Excellent

Comments

Leave New Comments


Article Content copyright by kane nelson
Everything else Copyright © by WorldofASP.NET 2008
 
Announcements
Earn Cash by writing an article or review
For more info Click here







Legend : - Within 3 Days - Within 6 Days - Within 9 Days

Home | Add Resources | Sponsored Listings | Advertise with Us | Contact Us | SiteMap | Link To Us | Contact Us
© 2002-2008 Worldofasp.net ASP.NET Directory, Hosting and Tutorials | All rights reserved
Our Partners : ASP.NET Web Hosting | Windows Web Hosting | FREE ASP.NET CMS | Phone Card | PHP Directory | Bangkok Hotels |Calling Card