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

  • SEARCH
  • Home
  • 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 7763049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:34:01+00:00 2026-06-01T14:34:01+00:00

I have an asp.net button wrapped inside of an UpdatePanel, and when clicked it

  • 0

I have an asp.net button wrapped inside of an UpdatePanel, and when clicked it does an asynchronous postback and registers some javascript that shows a jquery dialog.

protected void btnAddData(object sender, EventArgs e) {
    StringBuilder jqueryDialog = new StringBuilder();
    jqueryDialog.Append("$(document).ready(function() {");
    jqueryDialog.Append("RefreshData();");
    jqueryDialog.Append("$('#divData').dialog({ modal: false, draggable: true, title: 'Historical Data', width: 700 });");
    jqueryDialog.Append("});");

    ScriptManager sm = ScriptManager.GetCurrent(this);
    if (sm != null && sm.IsInAsyncPostBack) {
        ScriptManager.RegisterClientScriptBlock(
            this, typeof(Page), Guid.NewGuid().ToString(),
            jqueryDialog.ToString(), true);
    }
}

As you can see the javascript first calls a function named RefreshData(), which function exists in my markup as javascript.

<script type="text/javascript" language="javascript">
    if ($) {
        $(document).ready(function () {
            function RefreshData() {
                alert("Data Refreshed!");
            }
        });
    }
</script>

However, Firefox is giving an error that says the RefreshData is not defined. Does that mean any javascript that I register on an asynchronous postback will be unable to use
javascript functions that I have defined in my markup?

Thanks for the help.

  • 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-06-01T14:34:03+00:00Added an answer on June 1, 2026 at 2:34 pm

    Don’t define the RefreshData function inside the document.ready function which is an anonymous callback. Define it outside so that it is accessible to the outside:

    <script type="text/javascript">
        if (typeof($) != 'undefined') {
            function RefreshData() {
                alert("Data Refreshed!");
            }
        }
    </script>
    

    Also you probably don’t need to wrap in a document.ready your server side include:

    StringBuilder jqueryDialog = new StringBuilder();
    jqueryDialog.Append("RefreshData();");
    jqueryDialog.Append("$('#divData').dialog({ modal: false, draggable: true, title: 'Historical Data', width: 700 });");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net button, that when clicked calls a code behind function. The
I know that ASP.NET controls such as the button have the postback event model.
I have a ASP.NET page with an asp:button that is not visible. I can't
I have an ASP.NET button. When the button is clicked, I'd like a modal
In my ASP.NET web-based application, I have a normal ASP.NET button that has a
I noticed that in chrome if you have an asp.net image button and do
I have some javascript on an asp.net page code behind, but whenever the page
I have an ASP.Net-Button which, when clicked, executes client side and server side code.
I have a custom ASP.NET button with an image element inside it (and an
I need some help with jQuery and stopping an asp.net button postback. If you

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.