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 4267634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:55:34+00:00 2026-05-21T06:55:34+00:00

I’ve got an ASP.NET web form which uses UpdatePanels to allow partial page postbacks.

  • 0

I’ve got an ASP.NET web form which uses UpdatePanels to allow partial page postbacks. Within one of my UpdatePanels, I’m using the AutoCompleteExtender from the AjaxControlToolkit to call a WebMethod on my page to asynchronously retrieve a list of ProjectNames and their associated ProjectID values. When I select an item from the list, I’m using jQuery to save the ProjectID value to a HiddenField server control. I need this value when I click on the Submit button within the UpdatePanel to execute a database query. So far, everything works just great. Here’s the relevant client-side code:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="txtProjectName" Width="200" ToolTip="Type the first few characters of the project to search for" runat="server"></asp:TextBox>
        <ajaxToolkit:AutoCompleteExtender ID="AutoComplete1" TargetControlID="txtProjectName" MinimumPrefixLength="2"
            CompletionInterval="250" CompletionSetCount="20" ServiceMethod="GetProjectCompletionList"
            ServicePath="Default.aspx" runat="server" OnClientItemSelected="itemSelected" />
        <asp:HiddenField ID="hdnProjectID" runat="server" />
        <asp:Label ID="lblProjectName" runat="server"></asp:Label>
        <script type="text/javascript">
            function itemSelected(source, eventArgs) {
                $get('<%= hdnProjectID.ClientID %>').value = eventArgs.get_value();
                $get('<%= lblProjectName.ClientID %>').innerHTML = eventArgs.get_text();
            }
        </script>
        <br /><br />
        <asp:Button ID="btnSubmit" Text="Submit" runat="server" />
    </ContentTemplate>
</asp:UpdatePanel>

But, I also want to display the selected ProjectName text somewhere outside of the TextBox. The reason for this is I want a clear way to visually differentiate between a value in the TextBox that matched an item in the list returned by the AutoCompleteExtender and any old extraneous text leftover that didn’t match anything. So, I’ve tried displaying the selected text in a Label control, but as soon as the postback occurs, this value disappears. I’ve tried using a variety of server and HTML controls, but the behavior is the same… except with the ASP.NET HiddenField control. I’m not sure why this control retains these values across postbacks when the others don’t, but I’m still left without a complete solution.

I have found that if the Label I’m using to display the value is OUTSIDE of the UpdatePanel, it works fine, but the way my form is currently laid out, this isn’t an option. I realize there are some better alternatives to using UpdatePanel when you need more granular control of what to update during partial page postbacks, but I’d rather than delve into that at this time if there is a simpler solution to my problem.

  • 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-21T06:55:35+00:00Added an answer on May 21, 2026 at 6:55 am

    Your Label control is cleared during partial postbacks because it resides in the UpdatePanel, so it gets refreshed, but there is no provision to post its “value” (actually its inner text) back to the server, so the refresh resets it.

    You’ll need to use a web control that can post its current value back to the server. I’d suggest a TextBox control in read-only mode: it should work on most browsers, and you can style it to make it look like a label.

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

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
i got an object with contents of html markup in it, for example: string
I've got a string that has curly quotes in it. I'd like to replace
I have a JSP page retrieving data and when single or double quotes are
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Does anyone know how can I replace this 2 symbol below from the string

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.