| | |
Static Textbox Data (bit of a conundrum)
Please support our ASP.NET advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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)
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)
ASP.NET Syntax (Toggle Plain Text)
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnSave.Click Dim str As String = "" str = txtAso.Text & "|" & txtPer.Text & "|" & txtCat.Text & "|" & _ ddlMonth.SelectedItem.Text & "|" & ddlYear.SelectedItem.Text & "|" Dim DataCookie As New HttpCookie("TMDBdata", str) Response.Cookies.Add(DataCookie) Response.Redirect("data.aspx") End Sub Private Sub LoadChanges() If Request.Cookies("TMDBdata") IsNot Nothing Then Dim str As String = Request.Cookies("TMDBdata").Value Dim count As Integer = 0 Dim strChar As String = "" Dim strTmp As String = "" Dim strAso As String = "" Dim strPer As String = "" Dim strCat As String = "" Dim strMon As String = "" Dim strYer As String = "" Dim i As Integer For i = 0 To str.Length - 1 strChar = str(i) If strChar.Equals("|") Then count += 1 End If If count = 0 Then strAso &= strChar ElseIf count = 1 Then strPer &= strChar ElseIf count = 2 Then strCat &= strChar ElseIf count = 3 Then strMon &= strChar ElseIf count = 4 Then strYer &= strChar End If Next txtAso.Text = strAso.Replace("|", "") txtPer.Text = strPer.Replace("|", "") txtCat.Text = strCat.Replace("|", "") ddlMonth.SelectedValue = strMon.Replace("|", "") ddlYear.SelectedValue = strYer.Replace("|", "") End If End Sub
keep it simple.
use suggestions wisely.
use suggestions wisely.
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
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.
use suggestions wisely.
![]() |
Other Threads in the ASP.NET Forum
- Previous Thread: Versioning ASP.Net Website
- Next Thread: read Excel chart data in C#
Views: 511 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net box browser button c# checkbox click commonfunctions complex connection dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dropdownlist dynamically edit editing expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis javascript list listbox login microsoft migration mono mouse mssql news numerical opera panelmasterpagebuttoncontrols parent problem project radio redirect registration relationaldatabases reportemail richtextbox rows save schoolproject search security select services session silverlight smartcard smoobjects software sql sql-server sqlserver2005 suse textbox theft tracking unauthorized validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





