Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retain form value but reset query to null for next input . . . .

Status
Not open for further replies.

proximity

Technical User
Sep 19, 2002
132
GB
Hi,

Here's is something which sounds so simple to do . . . . but is proving a mega headache.

In a nutshell, I have a text box box and an asp:net form on a web page (C#). A user types in a value and presses the enter or return key. This then sends the user entered value to the database (stored procedure), returns the value and displays it in the form.

This works well but the user wants the following behaviour: type in value, retrieve value, reset the text box with focus and default value of null . . . .. (easy enough) . . . . . . but still keep on screen the original returned value (how to do this?) until a new value is entered.

Is anyone able to point me in the right direction for this?
 
.Net will display the entered value because form values that are posted are shown on a postback.

You should be able to clear the textbox in the page_load event. You can also do it with javascript.
 
It's likely the postback that is the problem . . . . if I clear the text box on page_load, it also clears the results from the form, which is not the behaviour I want: I want the results to stay put - but the text box to clear.
 
When you say you want the result to stay put.. what do you mean?
You say the user enters a value and you save that to a DB.
Then you want to show the entered value in a label or some control? Where is this value coming from? Are you retrieving it from the DB, or are you using the textbox value?

Need more clarification and maybe some code you are trying.
 
Hi, thanks for the replies . . . .

What I mean is that user, say, enters 123456 in text box. This then gets sent to the database, record 123456 is retrieved and displayed in the form (no data is being stored, just retrieved). Once the record is retrieved, I want the retrieved record to remain visible in the form but the text box to receive focus and to clear ready for the next query.

Like I say, no problem getting the box to clear and get focus. However, all it seems to do is send the null to the database! I've tried auto post back stuff, page load and nothing seems to give me what I want . . . .
 
Now it is more clear.
After you get the data back from the DB and populate the form, then clear the textbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top