Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3967710
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:45:10+00:00 2026-05-20T03:45:10+00:00

I have an ASP.Net UpdatePanel that updates on a timer. Within the UpdatePanel and

  • 0

I have an ASP.Net UpdatePanel that updates on a timer. Within the UpdatePanel and nested in a GridView, I have a TextBox that the user enters a value in with a submit button. Everything works fine, except if the user does not submit the value before the timed interval, the text is removed from the TextBox.

Is there a way to persist the user entry into the TextBox between updates? Is there a better way of doing this?

All suggestions welcome.

Respectfully,

Ray K. Ragan

Code Postscript:

aspx:

<script type="text/javascript">
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    prm.add_beginRequest(beginRequest);

    function beginRequest() {
        prm._scrollPosition = null;
    } 
</script> 

<asp:Timer ID="Timer1" runat="server" Interval="900" OnTick="Timer1_Tick"></asp:Timer>

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
    <ContentTemplate>
    <asp:DataList RepeatColumns="5" RepeatDirection="Horizontal"  ID="dlMine" runat="server" OnItemCommand="Item_Command">
        <ItemTemplate>
            <div style="border:1px solid black;margin:3px;height:300px;text-align:center;padding:5px;">
                <div style="width:150px;">
                <asp:Label ID="lblTitle" runat="server" Text='<%# left(DataBinder.Eval(Container.DataItem,"title").ToString(), 75) %>'></asp:Label>
                </div>   
                    <asp:Label ID="Label1" runat="server" Text='<%# (DateTime)DataBinder.Eval(Container.DataItem,"end_date") %>'></asp:Label>
                    <br />
                    <asp:Label ID="Label2" runat="server" Text='<%# String.Format("{0:C}",DataBinder.Eval(Container.DataItem,"current_value")) %>'></asp:Label>
                    <br />

                    <asp:TextBox ID="txtNewValue" runat="server"></asp:TextBox>

                    <asp:Button Visible='<%# (isInThePast((DateTime)DataBinder.Eval(Container.DataItem,"end_date"))) ? false : true %>' CssClass="bid_button" runat="server" CommandArgument='<%# Eval("ID") %>' CommandName="Revalue" ID="btnBid" Text="Submit New Valuation" />                  
                </div>
        </ItemTemplate>
    </asp:DataList>
    </ContentTemplate>    
    </asp:UpdatePanel>

Codebehind:

    protected void Page_Load(object sender, EventArgs e)
            {
                Timer1.Tick += new EventHandler<EventArgs>(Timer1_Tick);


                if (!IsPostBack)
                {
                    dataBindList();
                }
            }

            protected void dataBindList()
            {
                if (Request.QueryString["GroupID"] != null)//Are they coming here with a URL var? If so, build content object
                {
                    List<Item> itemList = ItemManager.getItemsByGroupID(Request.QueryString["GroupID"].ToString());

                    dlMine.DataSource = itemList.Take(15);
                    dlMine.DataBind();
                }
            }

            protected void Timer1_Tick(object sender, EventArgs e)
            {
                dataBindList();
                UpdatePanel1.Update();
            }

protected void Item_Command(Object sender, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Revalue")
            {
                Person p = (Person)Session["Person"];

                foreach (DataListItem item in dlMine.Items)
                {


                    string textBoxText = ((TextBox)item.FindControl("txtNewValue")).Text;

                    Utilities.writeLog("txtNewValue: " + textBoxText, 1);

                }            


                dataBindList();
                UpdatePanel1.Update();
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:45:10+00:00Added an answer on May 20, 2026 at 3:45 am

    You’re rebinding the DataList every time the Timer ticks. All changes in the ItemTemplates of the DataList will be lost on postback.

    Why not use Javascript to “pause” the timer whenver one of the textboxes gains focus. This will prevent the Timer from firing and let users finish entering text. Once they leave the textbox of “onblur” then you can restart the timer.

    Update

    The following will take a bit of effort to make it happen but you can do something like:

    • When the Timer posts back, before rebinding, iterate over the DataList while searching for textboxes with text in them. Something like:

    foreach (DataListItem item in dlMine.Items)
    {
    //find the textbox control and check for text
    }

    • At this point, you’ll know which rows need there textboxes repopulated. Store this information in a hashtable.

    In the DataList ItemDataBound event, check each rowID against the hashtable to see if its corresponding textbox exists. If so, repopulate the textbox in the DataList row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the ASP net Ajax toolkit and have a GridView within the UpdatePanel
When I have a regular textbox in a UpdatePanel (not an ASP.NET control) with
I have an ASP.Net 2.0 page that contains two UpdatePanels. The first panel contains
I have an ASP.Net CheckBoxList control inside an Ajax UpdatePanel. I will include the
I have asp.net form that contains fields. When I access this window, my javascript
I have a ASP.NET page with an asp:button that is not visible. I can't
I'm using an Ajax update panel and have recently added ASP.NET tracing code to
I have ASP.NET web pages for which I want to build automated tests (using
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>
So I have ASP.NET running on the server in IIS7. I think I'm going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.