473,770 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

values lost on postback when using ENTER key, help

Using C# and JavaScript Framework 2.0

My users want to be able to start a search by clicking the enter key. Since
the page uses View control, I placed an onkeypress event on the table for
each view to check for keyCode 13. If it detects the enter key, then it calls
a JS function that does some validation and then calls the button click that
should have been fired for the active view. For example:

document.getEle mentById("ctl03 _btnSmartSearch ").click()

Everything works great. Both my OnClientClick and OnClick attributes for the
button appear to fire. On the postback though, all my values are gone. I cant
even Request them. But if I physically click the same button with the mouse,
all my values are there. Is there a view state or something I missing that
needs to occur when I call the click via JS verses using the mouse to click
the button?
help
--
JP
..NET Software Developer
Apr 6 '07 #1
1 1359

JP wrote:
Using C# and JavaScript Framework 2.0

My users want to be able to start a search by clicking the enter key. Since
the page uses View control, I placed an onkeypress event on the table for
each view to check for keyCode 13. If it detects the enter key, then it calls
a JS function that does some validation and then calls the button click that
should have been fired for the active view. For example:

document.getEle mentById("ctl03 _btnSmartSearch ").click()

Everything works great. Both my OnClientClick and OnClick attributes for the
button appear to fire. On the postback though, all my values are gone. I cant
even Request them. But if I physically click the same button with the mouse,
all my values are there. Is there a view state or something I missing that
needs to occur when I call the click via JS verses using the mouse to click
the button?
help
--
JP
.NET Software Developer

If I understand it correctly it occurs when user types a search
keyword and then presses Enter?
It can happens because onchange event occurs only after you leave the
input field. As a variant you can try to focus the btnSmartSearch
button.
Example:
document.getEle mentById("ctl03 _btnSmartSearch ").focus();
document.getEle mentById("ctl03 _btnSmartSearch ").click();

Apr 6 '07 #2

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

Similar topics

3
1584
by: Ron Wallegie | last post by:
I developed a webesite using c#. I have a dropdownlist wich is filled with database values. When i click on a button on the same page all values are lost in the dropdownlist. The most common answer is to populate the ddl in "if !is postback" which i did. When i debug it seems that before the postback all values are lost. When i tried to do the same on my local machine (localhost) everything works fine. Can someone please help
3
1449
by: Rajesh | last post by:
Hello all, I have a problem here. I have a procedure called FillForm() where I populate values for some hidden asp:textboxes. But after I do a postback, my values in the textboxes are lost and I see only "" values. Hope someone can help me with this. Thank you.
2
5013
by: Ashish | last post by:
Hi All, I have a server runnable textbox control. I also have a server side button object but I hook up javascript to it to show a modal dialog. Upon return it places the value in the textbox (client side script). The problem is that after it places the value, postback occurs and value is lost. I have tried overriding SaveViewState and LoadViewState but it doesnt help (for some super cool reason load is called first after postback rather...
6
4370
by: Neil | last post by:
Hi, I have an aspx page with a number of web controls on it and one of these is a cancel button. I want to check the page to see if the user has changed any of the controls, i..e typed some text in a textbox, changed a dropdown etc The reason I want to do this is when the user clicks cancel I want to notify them that their changes will be lost using a popup or something. My question is what is the best way to compare the page that...
2
2760
by: Alan Lambert | last post by:
I have a web page that contains, amongst other things, a DropDownList called drpProjectCodes) and a Panel (called pnlStatus) which contains six Checkboxes. drpProjectCodes contains a list of project codes plus an 'All' option. If All is selected then the user can selected statuses using the CheckBoxes otherwise the CheckBoxes are disabled by disabling pnlStatus. Several of the Checkboxes are checked by default. There are actually other...
6
5227
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I have also tried changing the second ListBox to an HtmlSelect control) using bog standard JavaScript code like so where "used" is the name of my <select> control: used.options = new Option(name, typeId); This all works fine and I can move across...
3
1166
by: Pipo | last post by:
Hi, I'm trying to make my own web custom control. I've made a control with 2 textboxes and 1 dropdownlist. But when I enter values in them and get a postback the values are gone. How can I hold the values typed in by the client?? (for processing on the server but also to display them back) tia
4
8204
by: Frank | last post by:
Hello everyone, I have a problem that the window.opener variable is lost once my popup page has a postback. On multiple pages they address this problem but I cannot find a correct answer. This is my situation: I have a main page which shows invoices. When a user clicks on the invoices they get a popup where they can alter the invoice which uses
5
4454
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not survive postback. This seems to be true. However, this seems to make dynamically adding controls rather pointless to me, since if you cannot retrieve the values of the controls when you perform a postback, why add the controls in the firstplace?...
0
9617
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10099
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...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8931
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
7456
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
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.