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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:45:46+00:00 2026-05-13T06:45:46+00:00

I am running into an issue with running javascript from an external javascript file

  • 0

I am running into an issue with running javascript from an external javascript file inside of an UpdatePanel. I am trying to get a color picker working inside of a ListView. The ListView is inside of an UpdatePanel.

I am using this color picker.

Here is what I have narrowed it down to:

  • If I use the color picker on a textbox outside of an UpdatePanel, it works perfectly fine through all postbacks.

  • If I use the color picker on a textbox inside of an UpdatePanel, it works, until I do an async postback(clicking on an “EDIT” button in the ListView). Once the UpdatePanel has done the postback, the textbox will no longer show the color picker when clicked. The same occurs when the textbox is in either the InsertItemTemplate or EditItemTemplate of the ListView.

If you would like to replicate it, simply download the color picker(it’s free), then add this to a webpage…

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<div>
    <asp:UpdatePanel ID="panel1" runat="server">
        <ContentTemplate>
            <asp:TextBox runat="server" ID="textbox" CssClass="color" />
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

When the page loads, the color picker works fine. When you click on the button(which does a postback), the color picker will no longer work.

Any ideas?

  • 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-13T06:45:47+00:00Added an answer on May 13, 2026 at 6:45 am

    After an asynchronous roundtrip, any startup scripts will not be run, which is likely why it doesn’t work after the AJAX callback. The color picker likely has functions which need to be executed on page load.

    I’ve run into this so many times that I wrote a small method to register my scripts in the code-behind, which handles both async and non-async round trips. Here’s the basic outline:

    private void RegisterClientStartupScript(string scriptKey, string scriptText)
    {
        ScriptManager sManager = ScriptManager.GetCurrent(this.Page);
    
        if (sManager != null && sManager.IsInAsyncPostBack)
        {
            //if a MS AJAX request, use the Scriptmanager class
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), scriptKey, scriptText, true);
        }
        else
        {
            //if a standard postback, use the standard ClientScript method
            scriptText = string.Concat("Sys.Application.add_load(function(){", scriptText, "});");
            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), scriptKey, scriptText, true);
        }
    }
    

    I actually baked the above into a base page class so that any page I’m working with can call this.RegisterClientStartupScript(...). To do that, simply create a base page class and include it there (making sure to mark protected not private or your inheriting page classes won’t be able access it).

    With the above code, I can confidently register client scripts regardless of whether the page is doing a postback or callback. Realizing you are using external script files, you could probably modify the above method to register external scripts rather than inline. Consult the ScriptManager class for more details, as there are several script registering methods…

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

Sidebar

Related Questions

I am currently running into an issue trying to create delegates from MethodInfo .
I'm running into an issue that's arising from the fact that one has to
I'm running into an issue where my deployment loops through Recycling. From Visual Studio:
I am running into an issue with a sqlite database program. I am trying
I'm running into a minor issue with some ASP.Net code I'm working on. For
I am running into an issue with the way my asynctasks are executed. Here's
I am running into an issue similar to the one described here: NSFetchedResultsControllerDelegate not
I'm running into an issue in that I have a document indexed with elasticsearch
I'm running into an issue on a clients production server where the month &
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng

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.