473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Clearing textboxes in a form

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;
}
Nov 19 '05 #1
1 1215
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

--
Munsifali Rashid
http://www.munit.co.uk/blog/

"Alex" <al*******@yandex.ru> wrote in message
news:Ot**************@TK2MSFTNGP10.phx.gbl...
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;
}

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Savvas | last post by:
Hi everybody, I have a lot of textboxes on my form and a "Clear" button. Is there a way with a for loop or something to clear the textboxes, instead of writing textboxName.clear? Thanks a lot
4
by: Ali | last post by:
I used to clear my page's control in Visual Studio 2003 using code like this: Dim c As Control For Each c In Page.Controls(1).Controls If TypeOf c Is TextBox Then CType(c, TextBox).Text = Nothing...
1
by: Shahid Juma | last post by:
Hi, I have a form and when the user clicks save, it will add all the details to the database. However, when I add it to the database, how do I clear the form values? What happens is that it...
2
by: Eytch | last post by:
Hey: I am a rookie developer so please bear with me. I want to develop a small application for my office but I am having trouble clearing a page that has required fields. If I make a textbox...
5
by: Stephen D Cook | last post by:
I'm trying to clear a form after the user clicks the Insert button so the textboxes are empty and the checkboxes are unchecked. When I try to put the code in the Click part of the Insert button, I...
9
by: Michael.Suarez | last post by:
foreach (TextBox tb in this.Controls) tb.Dispose(); What this does is clears every other textbox on the form. Suppose there are 10 textboxes... this will dispose the 1st one, then i guess...
3
by: cmrhema | last post by:
This is reference to Vandana Sridhar's refreshing the form http://www.thescripts.com/forum/thread619976.html The code displayed below did work. Dim Ctrl As Control For Each Ctrl In...
5
jgroos
by: jgroos | last post by:
Here is the situation: I have 25 textboxes that are all handled by the same TextChanged event handler. My problem is, when I click my "Clear" button on the form, it clears all the textboxes and...
2
by: rsteph | last post by:
I've got a form set up that has a series of textboxes to enter employee info, with a listbox at the bottom listing all the employees with their title (to make it easier to find employees to edit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.