473,804 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TextBox, Enter key stroke

126 New Member
Hi Good Guys,
I need your help. Please Help me and share your knowledge of sample coding with me.

The WEBFORM1.ASPX is working well and I am very Puzzle by the data entry TEXTBOX. Each time after the User has input the data and hit ENTER KEY, very strangely all the TEXTBOX contained data have been cleared off data.

How do I ensure that when ENTER KEY is pressed by user it will not removed all the TEXTBOX Data.

Here is the sample coding of the data entry TEXTBOX.:

Expand|Select|Wrap|Line Numbers
  1. <div class="LeftMargin">
  2.     <table style="width:100%;"          
  3.  
  4.     <!-- ------CustomerID and Address ------ -->
  5.      <tr>
  6.          <td align=left class="style2">
  7.              <asp:Label ID="lblCustID" CssClass="labelText" runat="server" Width="160px"   Text="Customer ID: *"></asp:Label>
  8.              <asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" ></asp:TextBox>
  9.          </td>
  10.                 &nbsp;
  11.           <td>
  12.             <asp:Label ID="lblCustAddr" CssClass="labelText" runat="server" Width="150px" Text="Address :  *"></asp:Label>
  13.           <asp:TextBox ID="txtCustAddr" CssClass="textbox" Width="250px"  runat="server" ></asp:TextBox >
  14.           </td>                       
  15.      </tr>                    
  16.             <!-- ------ Contact name and City ------ --> 
  17.      <tr>
  18.           <td align=left class="style3">
  19.               <asp:Label ID="lblContname" CssClass="labelText" runat="server" Width="160px"  Text="Contact Name :*"></asp:Label>
  20.               <asp:TextBox ID="txtContName" CssClass="textbox" Width="300px" runat="server" ></asp:TextBox>
  21.           </td>
  22.                 &nbsp;
  23.           <td class="style1">
  24.                <asp:Label ID="lblCity" CssClass="labelText" runat="server" Width="150px" Text="City : *"></asp:Label>
  25.                <asp:TextBox ID="txtCity" CssClass="textbox" Width="250px" runat="server" ></asp:TextBox> 
  26.          </td>                     
  27.        /tr>
  28.  
  29.         <!-- ------ Only PostCode ------ -->
  30.      <tr>
  31.           <td align=left class="style2">
  32.              <asp:Label ID="lblBlank1" CssClass="labelText" runat="server" Width="460px" Text=""  ></asp:Label>                            
  33.           </td>
  34.                 &nbsp;
  35.           <td>
  36.                <asp:Label ID="lblPostCode" CssClass="labelText" runat="server"  Width="150px" Text="Post Code: * "></asp:Label>
  37.                <asp:TextBox ID="txtPostCode" CssClass="textbox" Width="250px" runat="server" ></asp:TextBox>
  38.          </td>
  39.    </tr>                     
  40.  
  41.   </table>
  42.  </div>
  43.  

Thank You.

Have a Good Day.
Cheers,
Lennie
Aug 2 '10 #1
8 3490
MrMancunian
569 Recognized Expert Contributor
Hi Lennie,

First, read up on this article: Understanding ASP.NET View State. It explains a lot about ASP.NET page life cycles. You need to actively save data in your controls. You can do this by adding a parameter to a textbox: EnableViewState .

Change
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" ></asp:TextBox>
to
Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" EnableViewState="True" ></asp:TextBox>
Good luck!

Steven
Aug 2 '10 #2
lenniekuah
126 New Member
Hi MrMancunian

I did change made changes as per your suggestion but it's not working.

Here are the few sample coding of the changes I made and tested it out

Expand|Select|Wrap|Line Numbers
  1. <asp:TextBox ID="txtCity" CssClass="textbox" Width="250px" runat="server" EnableViewState="true"></asp:TextBox> 
  2. <asp:TextBox ID="txtPostCode" CssClass="textbox" Width="250px" runat="server" EnableViewState="true" ></asp:TextBox>
  3. <asp:TextBox ID="txtCountry" CssClass="textbox" Width="250px" runat="server" EnableViewState="true"   ></asp:TextBox>
  4.  
  5.  
Aug 2 '10 #3
MrMancunian
569 Recognized Expert Contributor
@lenniekuah
Did you read the article I linked you to?
Aug 2 '10 #4
lenniekuah
126 New Member
Yes, I did read the article at the URL Link that you provided. I do not understand it as I cannot find the article relating to the TEXTBOX ENTER Key press situation. If there are sample coding relating to it I will be easier to understand logically.
Aug 2 '10 #5
Frinavale
9,735 Recognized Expert Moderator Expert
Hi Lenniekuah :)

When you hit the enter key on a page it does the "default action" which typically means that a submit button submits the page to the server.

Since enabling viewstate didn't work for you then I suggest you take a look at your Page Load event to see if you are clearing the text boxes there...

If not there, then check the button handling code to see if you are removing the text somewhere in that code.

Edit: oh wait a second.....are you using UpdatePanels?

-Frinny
Aug 2 '10 #6
lenniekuah
126 New Member
Hi Frinavale.

Thank you very much for your suggestion.

While testing it I set the debugger Breakpoint and noticed that when I press ENTER KEY on a TEXTBOX, These are the sequent of events. It does a PAGE LOAD event then BtnGVFill_Click .

This BtnGVFill_Click contain the function the clear the TextBox. List below are the coding of Page Load and BtnGVFill_Click event:


Expand|Select|Wrap|Line Numbers
  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.    'retrieve connection string from Web.config
  3.     connstr = ConfigurationManager.ConnectionStrings("DataConnstr").ConnectionString
  4.  
  5.         If IsPostBack Then
  6.             intPage = 1
  7.             strCustID = Session("custid")
  8.         End If
  9.     End Sub
  10.  
  11.     Protected Sub BtnGVFill_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGVFill.Click
  12.  
  13.         Dim intTotalPageCnt As Integer = 0
  14.         GridView1.PageIndex = intPage - 1
  15.         FLoadGridView()
  16.         FCleartextBox()
  17.  
  18.         intTotalPageCnt = GridView1.PageCount
  19.         Me.lblPage.Text = "Page : " & CType(intPage, String) & " of " & CType(intTotalPageCnt, String)
  20.  
  21.     End Sub
  22.  
  23.  
----------------------------------------------------------------
Regarding UPDATEPANELS , where about it it ? this is something new to me


I welcome your suggestion or sample coding to fix the problem. You are very awesome and wonderful in sharing information. I need your help.

Thank you,

Have a Good Day.
Cheers,
Lennie
Aug 2 '10 #7
Frinavale
9,735 Recognized Expert Moderator Expert
Check out the MSDN Library regarding .NET related questions :)

This library has documentation on all .NET controls, concepts etc. It's the resource that I constantly use whenever I'm working in .NET

There are quite a few articles on the UpdatePanel there :)

-Frinny
Aug 3 '10 #8
lenniekuah
126 New Member
Hi Awesome Frinavale,
Thank you very much for helping me. You are very wondeful and generous in sharing information with me.

My codings are now working on the Web Page.
This is a sample of my amended coding:

I added this AutoPostBack ="False"

Expand|Select|Wrap|Line Numbers
  1.  
  2.   <asp:TextBox ID="txtCustAddr" CssClass="textbox" Width="250px"  runat="server"  EnableViewState="true" AutoPostBack="false" TabIndex="3"  >
  3. </asp:TextBox 
  4.  
Aug 3 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1557
by: | last post by:
Hi , I did ask before but got no replies. I have a series of textboxes, In Enter event I need to set the focus to a different textbox I am having problems when I set focus within the Textbox Enter event. It is looping thru the events. Does anyone know how I can set focus to another object when the Textbox has received focus either by keyboard or mouse event.
4
5968
by: ShoCkwave | last post by:
I assigned Enter key to do sth after I write sth to a TextBox but I gives me a system sound like "this is not multiline textbox enter does not work here " and Beeps. I dont want this sound to be played. How can I avoid this? Thanks... Posted at: http://www.groupsrv.com Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
5
2025
by: DotNetGruven | last post by:
Hi, I have a web form which has: - Login area with - email textbox - password textbox - <enter> button to log in - search area with - string to search for textbox
6
3313
by: Bruce D | last post by:
I have a datagrid (uggg) that I use and create the columns programmatically...see below. objCol = New DataGridTextBoxColumn objCol.MappingName = "amount" objCol.HeaderText = "Amount" objCol.Width = 60 objCol.Format = "C" objDGTS.GridColumnStyles.Add(objCol) ' create keypress, validating events for this textbox column only Dim dgtb As DataGridTextBox = CType(objCol.TextBox, DataGridTextBox)
2
7826
by: Boki | last post by:
Dear All, What is the different between Enter and GotFocus events? Best reagrds, Boki.
1
1215
by: teo | last post by:
Hallo, I'd like to write in a Textbox1, press Enter on the keybord, and fire the Click event of a Button (unique Button control on the web form). Now: if a second Textbox2 is present on the web form all is accomplished OK
4
3824
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In multiLine textBox, enter moves to the next line, how can i overwrite it, so enter will move to the next control and ctrl + enter will move to the next line? Thanks, Gidi.
8
36906
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { txtDummie.BackColor=Color.Red; }
2
3729
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical analysis followed by plotting a graph). Since it is relatively slow (less than a second, but makes the updating sluggish) I only want it to be triggered when the value in one of the textboxes is actually changed by the user - pressing Enter or leaving...
0
9584
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
10583
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
10337
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
10082
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
9160
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
7622
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
6854
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();...
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
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.