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.: -
<div class="LeftMargin">
-
<table style="width:100%;"
-
-
<!-- ------CustomerID and Address ------ -->
-
<tr>
-
<td align=left class="style2">
-
<asp:Label ID="lblCustID" CssClass="labelText" runat="server" Width="160px" Text="Customer ID: *"></asp:Label>
-
<asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" ></asp:TextBox>
-
</td>
-
-
<td>
-
<asp:Label ID="lblCustAddr" CssClass="labelText" runat="server" Width="150px" Text="Address : *"></asp:Label>
-
<asp:TextBox ID="txtCustAddr" CssClass="textbox" Width="250px" runat="server" ></asp:TextBox >
-
</td>
-
</tr>
-
<!-- ------ Contact name and City ------ -->
-
<tr>
-
<td align=left class="style3">
-
<asp:Label ID="lblContname" CssClass="labelText" runat="server" Width="160px" Text="Contact Name :*"></asp:Label>
-
<asp:TextBox ID="txtContName" CssClass="textbox" Width="300px" runat="server" ></asp:TextBox>
-
</td>
-
-
<td class="style1">
-
<asp:Label ID="lblCity" CssClass="labelText" runat="server" Width="150px" Text="City : *"></asp:Label>
-
<asp:TextBox ID="txtCity" CssClass="textbox" Width="250px" runat="server" ></asp:TextBox>
-
</td>
-
/tr>
-
-
<!-- ------ Only PostCode ------ -->
-
<tr>
-
<td align=left class="style2">
-
<asp:Label ID="lblBlank1" CssClass="labelText" runat="server" Width="460px" Text="" ></asp:Label>
-
</td>
-
-
<td>
-
<asp:Label ID="lblPostCode" CssClass="labelText" runat="server" Width="150px" Text="Post Code: * "></asp:Label>
-
<asp:TextBox ID="txtPostCode" CssClass="textbox" Width="250px" runat="server" ></asp:TextBox>
-
</td>
-
</tr>
-
-
</table>
-
</div>
-
Thank You.
Have a Good Day.
Cheers,
Lennie
8 3490
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 - <asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" ></asp:TextBox>
to - <asp:TextBox ID="txtCustID" CssClass="textbox" runat="server" EnableViewState="True" ></asp:TextBox>
Good luck!
Steven
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 -
<asp:TextBox ID="txtCity" CssClass="textbox" Width="250px" runat="server" EnableViewState="true"></asp:TextBox>
-
<asp:TextBox ID="txtPostCode" CssClass="textbox" Width="250px" runat="server" EnableViewState="true" ></asp:TextBox>
-
<asp:TextBox ID="txtCountry" CssClass="textbox" Width="250px" runat="server" EnableViewState="true" ></asp:TextBox>
-
-
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.
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
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: -
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
'retrieve connection string from Web.config
-
connstr = ConfigurationManager.ConnectionStrings("DataConnstr").ConnectionString
-
-
If IsPostBack Then
-
intPage = 1
-
strCustID = Session("custid")
-
End If
-
End Sub
-
-
Protected Sub BtnGVFill_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnGVFill.Click
-
-
Dim intTotalPageCnt As Integer = 0
-
GridView1.PageIndex = intPage - 1
-
FLoadGridView()
-
FCleartextBox()
-
-
intTotalPageCnt = GridView1.PageCount
-
Me.lblPage.Text = "Page : " & CType(intPage, String) & " of " & CType(intTotalPageCnt, String)
-
-
End Sub
-
-
---------------------------------------------------------------- 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
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
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" -
-
<asp:TextBox ID="txtCustAddr" CssClass="textbox" Width="250px" runat="server" EnableViewState="true" AutoPostBack="false" TabIndex="3" >
-
</asp:TextBox
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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 **
|
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
|
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)
|
by: Boki |
last post by:
Dear All,
What is the different between Enter and GotFocus events?
Best reagrds,
Boki.
| |
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
|
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.
|
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;
}
|
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...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| | |