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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:04:57+00:00 2026-05-31T19:04:57+00:00

Here’s my code <script type=text/javascript> function getNextScroll(i){ <asp:Literal ID=infiniteScrollTableJS runat=server></asp:Literal> } </script> I am

  • 0

Here’s my code

<script type="text/javascript">
    function getNextScroll(i){
        <asp:Literal ID="infiniteScrollTableJS" runat="server"></asp:Literal>
    }
</script>

I am populating that Literal with some Javascript from the CodeBehind. This works great OnLoad. However, when I do a postback I have a problem. The Literal is updated on postback. The actual script that is inside the function actually gets changed (I can see it with Firebug). BUT, the function is unaware that there is new script in there, it just keeps running the old stuff.

So near as I can tell, I want to ‘re-initialize’ the code inside the function after postback.

I know how to call a function after postback using add_endRequest.

This problem is not unique to .NET or anything. In fact, I have a simple example here -> http://jsfiddle.net/7JxY7/1/ ‘Run Function’ will always alert ‘one’ even after the script contents are changed.

I feel like jQuery probably has something that I could use, but searching around I have found nothing.

EDIT:

I tried the suggestion by mblase75. This works great in Javascript ( more importantly, now I understand why) , however, given this approach, I still can’t get it working with the postback. Here is my updated code.

<script type="text/javascript">
    function getNextScroll(i){
        //some stuff
    }

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function (s, e) {
        //mblase75 suggestion
        getNextScroll = function (i){<asp:Literal ID="infiniteScrollTableJS" runat="server"></asp:Literal>};
    });
</script>

I thought this would work, but of course, it has the same problem as my original method. The Literal is actually changed, but the function doesn’t know about the change, it still has the original code

  • 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-31T19:04:58+00:00Added an answer on May 31, 2026 at 7:04 pm

    In JavaScript, a function is actually an object. So instead of trying to rewrite the <script> element with a string, replace the function (variable) name with a new function object:

    <script>
    goTest = function(){
        alert('one');                        
    }
    
    function changeTest1(){
        goTest = function(){alert('two');};
        alert('ok');
    }    
    </script>
    
    <a onclick="goTest();">Run Function</a><br/>
    <a onclick="changeTest1();">Change Function</a>
    ​
    

    http://jsfiddle.net/7JxY7/2/

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

Sidebar

Related Questions

Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
Here's the code in AlertTableView: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSInteger index = 12345; NSLog(@AlertTableView:
Here is an example: I write html code inside of textarea, then I swap
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is an example: I have the generic type called Account. I wish to
Here is my code, which takes two version identifiers in the form 1, 5,
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here is my code...I have two dimensional matrices A,B. I want to develop the

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.