Solved

Retain textbox values ?

Posted on 2004-04-09
6
1,741 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now