473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

how to retain value in a text box while passing information from one page to next in

38
I Have a textbox in a form. user can enter string value in it. page is posted in same page. after submitting the value, by get method, some other information will be displayed in mulitple pages.
its showing current number of records, but value of the TEXT BOX does not retain, as soon as user clicks next page.
anybody ne idea in that?
Aug 24 '07 #1
7 6944
JamieHowarth0
533 Expert 512MB
Hi Nudrat,

If you are doing this in classic ASP (v3), then it's a common symptom. Classic ASP doesn't save the ViewState of an element - so if you post a form to it's parent page, when the page reloads, the form data has disappeared.
The easy way of doing this is (as it's only a textbox) is as follows:

<input type="text" name="myTextBox" value="<%=Request.Form("myTextBox")%>" />

That way, when the page is being processed by the ASP extensions, the textbox will be automatically populated when loaded with whatever the user typed in there last time.

All the best,

medicineworker

N.B. As the problem is occurring when your user jumps to the next page, I take it your links are dynamically generated - so you have, say, 20 results per page, and then user can click page 1, page 2 etc.?
When doing search-engine type scripts, I pass a couple of QueryString parameters - namely whatever string the user is searching on ("searchq"), then how many results they want per page ("retmod"), and at what record index to begin printing results. That way, I can then automatically produce code for page numbers (page 1 of results etc.) like so:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. For I = 0 To Mod(rsResults.RecordCount,CInt(Request.QueryString("retmod")))
  3. %><a href="results.aspx?searchq=<%=Request.QueryString("searchq")%>&amp;retmod=<%=Request.QueryString("retmod")%>&amp;begin=<%=Request.QueryString("bc")%>"><%=I%></a>
  4. <%
  5. Next
  6. %>
Aug 24 '07 #2
nudrat
38
Hi,
I have already used the same code, which u have suggested. Its not working.
<input type="text" name="myTextBox" value="<%=Request.Form("myTextBox")%>" />
the value reatin as long as user is submitting it in a single page, but as soon as he clicks next page, value of the text box disappears.
Help is required.

Nudrat

Hi Nudrat,

If you are doing this in classic ASP (v3), then it's a common symptom. Classic ASP doesn't save the ViewState of an element - so if you post a form to it's parent page, when the page reloads, the form data has disappeared.
The easy way of doing this is (as it's only a textbox) is as follows:

<input type="text" name="myTextBox" value="<%=Request.Form("myTextBox")%>" />

That way, when the page is being processed by the ASP extensions, the textbox will be automatically populated when loaded with whatever the user typed in there last time.

All the best,

medicineworker

N.B. As the problem is occurring when your user jumps to the next page, I take it your links are dynamically generated - so you have, say, 20 results per page, and then user can click page 1, page 2 etc.?
When doing search-engine type scripts, I pass a couple of QueryString parameters - namely whatever string the user is searching on ("searchq"), then how many results they want per page ("retmod"), and at what record index to begin printing results. That way, I can then automatically produce code for page numbers (page 1 of results etc.) like so:
Expand|Select|Wrap|Line Numbers
  1. <%
  2. For I = 0 To Mod(rsResults.RecordCount,CInt(Request.QueryString("retmod")))
  3. %><a href="results.aspx?...
  4. <%
  5. Next
  6. %>
Aug 27 '07 #3
jhardman
3,406 Expert 2GB
nudrat,

I think MedicineWorker may have hit on something you didn't catch. The user has typed info into a text box in a form but is NOT SUBMITTING the form. If you need this data to be passed on to the next page, you will need to submit the data in one way or another. For example, if you want to still use the "next page" link, you could remove the href attribute of the link and add a onClick statement like this:
Expand|Select|Wrap|Line Numbers
  1. <a onClick="document.all.form1.action='nextPage.asp';document.all.form1.submit()">Next Page</a>
Let me know if this helps.

Jared
Aug 27 '07 #4
nudrat
38
Thanks for the reply jhardman,
i tried ur code, it didn't worked,.. im just pasting my total code. let me know, where im going wrong,
Expand|Select|Wrap|Line Numbers
  1. <%
  2. strURL=Request.ServerVariables("url")
  3. varX=Request.QueryString("txtText1") 
  4. set rsPaging=Server.CreateObject("adodb.recordset")
  5. strPaging="select * from nudrat where name='"&varX&"'"
  6. iPageSize = 1
  7.  
  8.     If Request.QueryString("page") = "" Then
  9.             iPageCurrent = 1
  10.     Else
  11.         iPageCurrent = CInt(Request.QueryString("page"))
  12.     End If
  13.  
  14.         rsPaging.PageSize = iPageSize
  15.         rsPaging.CacheSize = iPageSize
  16.          rsPaging.open strPaging,con, 3,1, &H0001    
  17.  
  18.  %>
  19.  <form action="ValFixed.asp" method="get" name="frm1">
  20. <input type="text" name="txtText1" id="txtText" value="<%=Request.QueryString("txtText1") 
  21. %>">
  22.  <input type="submit" value="click">
  23.  <%     
  24.         iPageCount = rsPaging.PageCount        
  25.     If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
  26.     If iPageCurrent < 1 Then iPageCurrent = 1
  27.     If iPageCount = 0 Then
  28. %>
  29.     <table align="center"><tr><td align="center">
  30.     <%    Response.Write "No records found!"%>
  31.                             </td></tr></table>                            <%Else                        rsPaging.AbsolutePage = iPageCurrent%>
  32.  
  33. <table width="404" border="1">
  34.   <tr>
  35.   <td width="33"><strong>SiNo</strong></td>
  36.     <td width="40"><strong>Name</strong></td>
  37.     <td width="27"><strong>Age</strong></td>
  38.     <td width="43"><strong>Salary</strong></td>
  39.     <td width="80"><strong>Designation</strong></td>
  40. <td width="141"><strong>Applied Date</strong></td>
  41.   </tr>
  42.   <% 
  43.   iRecordsShown = 0
  44.   Do While iRecordsShown < iPageSize And Not rsPaging.EOF 
  45.   %>
  46. <tr>
  47.   <td><%=rsPaging.absoluteposition%></td>
  48.   <td><%=rsPaging("Name")%></td>
  49.   <td><%=rsPaging("Age")%></td>
  50.   <td><%=rsPaging("Salary")%></td>
  51.   <td><%=rsPaging("Designation")%></td>
  52.   <td><%=rsPaging("MyDate")%></td>
  53.  
  54.   <%    iRecordsShown = iRecordsShown + 1
  55.             i=i+1                    rsPaging.MoveNext%>
  56.       </tr>                            <%Loop%>
  57. </table>
  58. <% end if %>
  59. <%If iPageCurrent > 1 Then
  60.     %>
  61.     <a href="<%=strURL%>?page=<%=iPageCurrent -1%>&myText=<%=Request.QueryString("txtText1") %>">Prev</a> 
  62.     <%
  63.             End If
  64.             For I = 1 To iPageCount
  65.             If I = iPageCurrent Then%>   <%= I %>    
  66.  <%Else%>
  67.     <a href="<%=strURL%>?page=<%=iPageCurrent %>&myText=<%=Request.QueryString("txtText1") %>"><%= I %></a> 
  68.     <%        End If
  69. Next 
  70. If iPageCurrent < iPageCount Then
  71. %>
  72.  <a href="<%=strURL%>?page=<%=iPageCurrent+1%>&myText=<%=Request.QueryString("txtText1") %>"> Next </a> 
  73.     <%
  74.         End If
  75. %>
  76.     </font></td>
  77.   <td> <p> <font size="2" face="Arial, Helvetica, sans-serif">Page <strong><%= iPageCurrent %></strong> of <strong><%= iPageCount %></strong></font> 
  78.     </p>
  79. </td>
  80. </div>
  81.  
  82.  
  83.  </form>
Regards
Nudrat

nudrat,

I think MedicineWorker may have hit on something you didn't catch. The user has typed info into a text box in a form but is NOT SUBMITTING the form. If you need this data to be passed on to the next page, you will need to submit the data in one way or another. For example, if you want to still use the "next page" link, you could remove the href attribute of the link and add a onClick statement like this:
Expand|Select|Wrap|Line Numbers
  1. <a onClick="document.all.form1.action='nextPage.asp';document.all.form1.submit()">Next Page</a>
Let me know if this helps.

Jared
Aug 28 '07 #5
markrawlingson
346 Expert 100+
I would try using POST instead of GET - let me know if that helps any.
Aug 28 '07 #6
jhardman
3,406 Expert 2GB
I notice that in this page you refer to the text in question as "txtText1", but you send it to the next page as "myText". Could this be causing your problem? When in doubt, it is often a good idea to list all of the data sent to your asp page:
Expand|Select|Wrap|Line Numbers
  1. for each x in request.querystring
  2.    response.write x & ": " & request.queryString(x) & "<br>" & vbNewLine
  3. next
  4.  
  5. for each x in request.form
  6.    response.write x & ": " & request.form(x) & "<br>" & vbNewLine
  7. next
  8.  
  9. for each x in request.cookies
  10.    response.write x & ": " & request.cookies(x) & "<br>" & vbNewLine
  11. next
  12.  
  13. for each x in request.serverVariables
  14.    response.write x & ": " & request.serverVariables(x) & "<br>" & vbNewLine
  15. next
now you probably don't need all of these, but this will verify what is being sent to the next page.

Jared
Aug 28 '07 #7
nudrat
38
Thanks Jared for the reply,
It worked at last,
I have to close the form tag after the submit button,
Paging code will appear when form tag has been closed.
myText is the alias name, so it will not make any difference.

Regards
Nudrat

I notice that in this page you refer to the text in question as "txtText1", but you send it to the next page as "myText". Could this be causing your problem? When in doubt, it is often a good idea to list all of the data sent to your asp page:
Expand|Select|Wrap|Line Numbers
  1. for each x in request.querystring
  2.    response.write x & ": " & request.queryString(x) & "<br>" & vbNewLine
  3. next
  4.  
  5. for each x in request.form
  6.    response.write x & ": " & request.form(x) & "<br>" & vbNewLine
  7. next
  8.  
  9. for each x in request.cookies
  10.    response.write x & ": " & request.cookies(x) & "<br>" & vbNewLine
  11. next
  12.  
  13. for each x in request.serverVariables
  14.    response.write x & ": " & request.serverVariables(x) & "<br>" & vbNewLine
  15. next
now you probably don't need all of these, but this will verify what is being sent to the next page.

Jared
Aug 31 '07 #8

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

Similar topics

4
by: melvynadam | last post by:
If I open a new page with very little text on it such as a bugmenot results page is there a way to select some of the text there and assign it to variables? Selecting all and copying to the...
3
by: Mark Harris | last post by:
I have an installer which uses a Customer Information page in it, is there an easy way to pass the serial number entered to a custom action? If not, where would i find the serial number in the...
3
by: A Ward | last post by:
I am trying to find a way to have multiple seperate ASP.Net applications where I can response.redirect() to a second web application and pass information. From what I have tried: * HTTP-GET - I...
2
by: BerkshireGuy | last post by:
I want to open a word document from an Access form and transfer data from the Access form to the Word Document. For instance, if a user clicks an option box on my access form, I want to pass...
3
by: Dhruba Bandopadhyay | last post by:
I am using a <asp:TextBox TextMode="Password"... etc. however it doesn't retain it's text through postbacks, whereas other textboxes do. Does anyone know how to retain the text?
1
by: nona | last post by:
Hi all, i need some help here, i'm using a datagrid on my ASP.net application, inside the datagrid was inserted a hyperlink on the table this hyperlink was passing information about the data set...
1
by: cmpcrand | last post by:
Hi again. I have created 2 web applications on the local server, in the form: http://localserver/TestApp1 http://localserver/TestApp2 I have set both of these pages to run in SqlServer mode...
1
by: destiny007 | last post by:
can any one help me to write code to capture selected text from a page but problem is that i am not able to decide where to call the functio.in this case the function is called in all cases of mouse...
6
by: iDesmet | last post by:
Good day! I was wondering if someone could show me the way with this little problem I have. I need to get the value/text of every checked SubItems in a listview so I can execute a Sub. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.