C# - Maintaining form fields values

U

User

Form A (Main)
Text Box 1
Text Box 2
Text Box 3

Form B (Pop-up)
Choose a selection for Form A/Text Box 3


Scenario:
1. User fills out the first two fields (Text Box 1 and Text Box 2) on
Form A

2. User clicks on a link for that spawns a pop-up window to choose a
selection that will populate Test Box 3 on Form A

3. After hitting the Submit button the page redirects to Form A
refreshing the page wiping the values from (Text Box 1 and Text Box
2).


Question: What can I do to maintain the values on Form A?




Thanks in advance...
 
E

Eliyahu Goldin

If all you want from Form B is just to pass a parameter back to Forma A,
Form B doesn't have to submit to the server. Open Form B from Form A with a
javascript call to showModalDialog and pass the selected value back with
returnValue. Since there won't be any refresh to Form A, the values of Text
Box 1 and 2 will persist.

Eliyahu
 
U

User

Eliyahu, thanks for the fast reply.

My apologizes but I need to elaborate on the process. I will try to
keep this short before it becomes a rat hole.


Form A (Main)
Text Box 1
Text Box 2
Text Box 3
Hidden Field
link to Form B

Note: Form A is a aspx page

Form B (Pop-up)
Choose a selection for Form A: Text Box 3 (For Displaying purposes
only) and a Hidden Field


Note: Form B is a asp page with Radio buttons with values from MS SQL

Scenario:
1. User fills out the first two fields (Text Box 1 and Text Box 2) on
Form A

2. User clicks on a link for that spawns a pop-up window to choose a
selection that will populate Test Box 3 and a Hidden Field on Form A
with a radio button

3. The Submit button is clicked

4.
a. aspx function will read the Request.Querystring
b. capture the value e.g. (10200~Product Name)
c. split the values based on the '~'
d.assigned the values into Text Box 3 (Product Name) and the Hidden
Field (10200) on Form A.

5. Form A values Text Box 1 and Text Box 2 are no longer there

So my new question is, there a better way of doing this or what is
the solution?

Once again thanks
 
E

Eliyahu Goldin

My suggestion is good for your scenario. You are passing the selection from
form B to form A via round trip to the server in a query string. This is
unnecessary. In form B, upon clicking Submit button, set window.returnValue
to whatever you want and call window.close(). If form B was called as a
modal dialog, form A will get the returnValue as a result value of the
showModalDialog call(). After this call, return value can be assigned to
Text Box 3. You can't program in ASP.NET without a bit of understanding
client-side javascript programming.

Good luck,

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top