Solved

Retain textbox values ?

Posted on 2004-04-09
6
1,750 Views
Last Modified: 2007-12-19
Im creating multiple textboxes dynamically in my class file.
So every time I do a postback, these textboxes are created again.
Is there anyway to retain their values ???
0
Comment
Question by:PBWMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 10793071
This is a Web app?

Are you testing the IsPostBack property, and only creasting the textboxes if that property is FALSE?

If Not IsPostBack then
   ' create texct boxes
Else
   'use the text  boxes that have already been created
End If

The first time the page is loaded, IsPostBack is False, so you create the text boxes, from then on, IsPostBack is True, and you use the text boxes.

AW
0
 
LVL 28

Expert Comment

by:iboutchkine
ID: 10793129
or you can save the textboxes values in the session and enter them to the textboxes on reload
0
 
LVL 1

Author Comment

by:PBWMan
ID: 10793305
This is what Im doing

I have a repeater control.
on every postback, I do the following in my aspx.vb :

rptListing.HeaderTemplate = New RenderExecutionResourceList(ListItemType.Header)
rptListing.ItemTemplate = New RenderExecutionResourceList(ListItemType.Item)
rptListing.AlternatingItemTemplate = New RenderExecutionResourceList(ListItemType.AlternatingItem)
rptListing.FooterTemplate = New RenderExecutionResourceList(ListItemType.Footer)
--Databinding() call happens here
-----------------------------------------------------------------------------------------------------------------
Public Class RenderExecutionResourceList
    Implements ITemplate

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements System.Web.UI.ITemplate.InstantiateIn
        Dim lc As New Literal
        Select Case TemplateType
            Case ListItemType.Header
                lc.Text = "<Table border=0 cellpadding=1 cellspacing=1 "
                lc.Text &= "class=ToDoListTable width=100%>"
                lc.Text &= "<tr>"................. and so on
            Case ListItemType.Item
                AddHandler lc.DataBinding, AddressOf ExecutionResourceListItem_Databinding
            Case ListItemType.AlternatingItem
                AddHandler lc.DataBinding, AddressOf ExecutionResourceListAltItem_Databinding
            Case ListItemType.Footer
                lc.Text = "</table>"
        End Select
        container.Controls.Add(lc)
    End Sub
-----------------------------------------------------------------------------------------------------------------
    Private Sub ExecutionResourceListItem_Databinding(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim lc As Literal
        lc = CType(sender, Literal)
        Dim container As RepeaterItem
        container = CType(lc.NamingContainer, RepeaterItem)
        Dim currID As String
        currID = CType(DataBinder.Eval(container.DataItem, "ID"), String)

        lc.Text = "<tr id=row" & currID & ">"
        lc.Text &= "<input type=text size=6 id=""txtAS" & currID & """ class=""smalltextleft"" value=" & DataBinder.Eval(container.DataItem, "ProjEnd") & " onfocus=""this.blur()"" onclick=""JavaScript:updateWritein('txtAS" & currID & "'); callDiv('calspace')"">"
       lc.Text &= "</td></tr>"
    End Sub

End Class
-----------------------------------------------------------------------------------------------------------------

As you can see, I cant put these values in session variables since there could be 1 record or 500.
And I tried using server controls, but they are too expensive - page takes pretty long to load.
The user will be entering his date and could sort or something that would cause the page to postback.
I need to save the dates.

Any ideas ????
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 100 total points
ID: 10794222
when the form posts back, inputs are available as request variables ..

read them off the request

this is the same way that viewstate works, its written as a hidden then read back.

Greg
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question