Static Textbox Data (bit of a conundrum)

Reply

Join Date: Oct 2007
Posts: 17
Reputation: diyerxa is an unknown quantity at this point 
Solved Threads: 0
diyerxa's Avatar
diyerxa diyerxa is offline Offline
Newbie Poster

Static Textbox Data (bit of a conundrum)

 
0
  #1
Jul 25th, 2008
I'm a VB.NET developer in training (still in college), and I'm working on my first ASP.NET web application. I'm extremely new to the concepts of ASP.NET and only know what I've read from a few chapters of a book.

That being said, I have a web form with 3 textboxes and 2 dropdownlists. When the page first loads, there is data that is pulled from a database and inserted into the textboxes and dropdownlists. I assign the data as follows:

textbox1.text = string1
dropdownlist1.selectedvalue = string2

so on and so forth.

The data in the textboxes and dropdownlists can be modified by the user. However, when I change the data in the textbox or the dropdownlist while the page is running and attempt to use the changed data in any other manner, it stays the same value as when the page first loaded.

I have tried two different scenarios. I have tried writing the modified data in the textboxes and dropdownlists to the database, and I have tried creating cookies with the modified data in the textboxes and dropdownlists. But the values stay the same as when the page first loaded.

if anyone can link me to a tip or offer some advice, I would greatly appreciate it. Thanks, Dave

below is my cookie code. I create when the user clicks a Save button. (i'm pretty sure the code is fine. however, the methodology may be all wrong)
  1. Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSave.Click
  2. Dim str As String = ""
  3. str = txtAso.Text & "|" & txtPer.Text & "|" & txtCat.Text & "|" & _
  4. ddlMonth.SelectedItem.Text & "|" & ddlYear.SelectedItem.Text & "|"
  5. Dim DataCookie As New HttpCookie("TMDBdata", str)
  6. Response.Cookies.Add(DataCookie)
  7. Response.Redirect("data.aspx")
  8. End Sub
  9.  
  10. Private Sub LoadChanges()
  11. If Request.Cookies("TMDBdata") IsNot Nothing Then
  12. Dim str As String = Request.Cookies("TMDBdata").Value
  13. Dim count As Integer = 0
  14. Dim strChar As String = ""
  15. Dim strTmp As String = ""
  16. Dim strAso As String = ""
  17. Dim strPer As String = ""
  18. Dim strCat As String = ""
  19. Dim strMon As String = ""
  20. Dim strYer As String = ""
  21. Dim i As Integer
  22. For i = 0 To str.Length - 1
  23. strChar = str(i)
  24. If strChar.Equals("|") Then
  25. count += 1
  26. End If
  27. If count = 0 Then
  28. strAso &= strChar
  29. ElseIf count = 1 Then
  30. strPer &= strChar
  31. ElseIf count = 2 Then
  32. strCat &= strChar
  33. ElseIf count = 3 Then
  34. strMon &= strChar
  35. ElseIf count = 4 Then
  36. strYer &= strChar
  37. End If
  38. Next
  39. txtAso.Text = strAso.Replace("|", "")
  40. txtPer.Text = strPer.Replace("|", "")
  41. txtCat.Text = strCat.Replace("|", "")
  42. ddlMonth.SelectedValue = strMon.Replace("|", "")
  43. ddlYear.SelectedValue = strYer.Replace("|", "")
  44. End If
  45. End Sub
keep it simple.
use suggestions wisely.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 17
Reputation: diyerxa is an unknown quantity at this point 
Solved Threads: 0
diyerxa's Avatar
diyerxa diyerxa is offline Offline
Newbie Poster

Re: Static Textbox Data (bit of a conundrum)

 
0
  #2
Jul 27th, 2008
After pulling my hair out for a couple days thinking about this (I took a break from writing code and decided to just think about it), the solution was extremely simple.

All I had to do was assign the strings to the textboxes in the Page_LoadComplete event, and that fixed it entirely.

(It's funny, I always seem to solve my own posts, no one seems to reply to any of them. I guess no one likes me
Last edited by diyerxa; Jul 27th, 2008 at 6:25 pm.
keep it simple.
use suggestions wisely.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum


Views: 511 | Replies: 1
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC