
How to create a guest book in ASP.Net?A guest book
for a website is a very important feature to know the feedback of the
users who are using the website. This feedback from the users helps in
refining the content or the services the website is intended for. Hence
many of the websites which provide distinct services go for guest book
features in their websites.
When you
open up a guest book you should be aware that you will not only get accolades
for the services but also curses when you do not provide proper services.
There are usually many so called bad guys who scold you and also write
some filthy stuff in your guest book. You should know how to handle such
messages. You can simply delete such messages from the guest book. Hence
a guest book should have a feature for you to delete unwanted messages
or messages that spoil your reputation. Creating
a guest book is easy if you use ASP.Net since you can avoid a lot of coding
that is done if you are using other technologies. You can use a simple
Access database to hold the messages that are written by the users of
the guest book. All you have to do is to read the message from the database
and display it in your webform. To display them it is better to have a
datagrid in the webform so that you can incorporate paging to display
limited number of messages in a particular page. When you are using a
database you are certain to use the ADO.Net for inserting, reading, updating,
and deleting the records in the database. For the sake of simplicity we
will see some code that is involved in inserting the records using ADO.Net
and some code to read the records and bind them to the datagrid so that
the guest book can be viewed. You need
to create an aspx page for the user to enter information about him and
his comments about the site. For this purpose you need to have text box
controls and label controls in your aspx page. For writing the comments
you can have multi-line text box control. To have multiple lines in the
textbox you can set the TextMode property of the textbox to
MultiLine. RequiredField validators can be used if do not
want the user to leave any field blank. Once you create this page for
entering data, you have to write the code to insert this data in to the
database. Assuming that you have created the required fields in the database,
the following code gives you an idea of how to insert the data in to the
Guest Book database. Private Sub
Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load qry = "Insert
into Guest_Book (name,country,comment) VALUES ('" & Name &
"',''" & Country & "','" & Comment &
"'" & ")" Try Response.Redirect("viewGB.aspx") End Sub When the
user is redirected to the view page to view the guest book the data from
the MSAccess database is retrieved and bound to a datagrid in the view
page. A sample code for this process in the view page is given below: Private Sub
Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load ds = New
DataSet() By changing
the qry string you can achieve task like deleting records
from the database and this can be done by the owner of the website. If
you work around the DataGrid during the design time you can set properties
so that you can sort the records displayed in the grid of the view page.
Thus a simple guest book can be created using the concepts of ADO.Net
very easily in ASP.Net.
_______________________________________________________________________
FREE
Subscription
Subscribe
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ |