Clearing textboxes in a form

A

Alex

Hi
I'm a beginner in ASP.NET.
I'm using 'AddContact.aspx' form to add a contact to DB, 'litStatus' literal
to show the result and Server.Transfer to clear inputs in the form.
The problem is i don't see the status message. The example is from a book
about ASP.NET.
Am i doing something wrong? If the code is wrong how can i clear the
textboxes and show the status?
Thanks.
try
{
adptContacts.Update(dsContacts);
litStatus.Text = rowNew.FirstName + " " + rowNew.LastName + " added
successfully";
Server.Transfer("AddContact.aspx");
}
catch (Exception Ex)
{
litStatus.Text = "Error occurred: " + Ex.Message;
}
 
M

Munsifali Rashid

The status message is being set correctly, but never displayed due to the
server transfer. ie. You're setting the label text, and then sending the
user to a new page before the HTML is returned to the user's browser.
Remove the server transfer, and manually clear the textboxes using
txtControl.Text = string.Empty; .

Hope this helps,

Mun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top