473,657 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Clearing textboxes in a form

Hi
I'm a beginner in ASP.NET.
I'm using 'AddContact.asp x' 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.Up date(dsContacts );
litStatus.Text = rowNew.FirstNam e + " " + rowNew.LastName + " added
successfully";
Server.Transfer ("AddContact.as px");
}
catch (Exception Ex)
{
litStatus.Text = "Error occurred: " + Ex.Message;
}
Nov 19 '05 #1
1 1234
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*******@yand ex.ru> wrote in message
news:Ot******** ******@TK2MSFTN GP10.phx.gbl...
Hi
I'm a beginner in ASP.NET.
I'm using 'AddContact.asp x' 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.Up date(dsContacts );
litStatus.Text = rowNew.FirstNam e + " " + rowNew.LastName + " added
successfully";
Server.Transfer ("AddContact.as px");
}
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
1851
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
4422
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 End If If TypeOf c Is DropDownList Then CType(c, DropDownList).SelectedIndex = 0 End If Next
1
1277
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 updates a label which I added informing that it was saved but the form is still filled in with values. Any ideas?
2
4930
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 required and then trigger it by not entering in any data the page seems to be totally locked. (Which makes sense because the Textbox is required) My question is: How can I code a button that overrides the required fields
5
3821
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 get an error telling me the Serial Number text box is empty. If I put the code in the MouseUp part, it doesn't do anything. please direct me to what I am doing wrong.
9
2185
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 whatever list of textboxes it's maintaining gets shifted, so the 2nd is now the 1st in the list, so when it goes to the next one, it is destroying the 3rd textbox, leaving the 2nd one safe...
3
1662
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 Me.Controls If TypeOf Ctrl Is TextBox Then Ctrl.Text = "" Next But I have three frames inside the form
5
10796
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 then fires my TextChanged event handler for each of the 25 textboxes, because their text is being "changed". I know this is how it is supposed to work, but it makes clearing my form take WAY too long! :) Is there any way I can clear the event queue...
2
5304
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 information). I'm having a problem though - if I click around on the listbox to view some employee records, then want to add a new employee, when I click on the add record button it edits the last employee I looked at with the new information. I've...
0
8316
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6174
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.