Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
876 views
in Technique[技术] by (71.8m points)

asp.net - Execute javascript after a partial postback of an updatepanel?

I have a page that add tree file script to it .

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/init.js"></script>
<script type="text/javascript" src="js/easing.js"></script>

I have a updatepanel with a dropdownlist. When run SelectedIndexChanged event (partial postback of an updatepanel), don't execute javascript .

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the pageLoad function:

function pageLoad(sender, args) {
  InitialiseSettings();
}

function InitialiseSettings(){
    // replace your DOM Loaded settings here. 
    // If you already have document.ready event, 
    // just take the function part and replace here. 
    // Not with document.ready 
    $(element).slideUp(1000, method, callback});

    $(element).slideUp({
                   duration: 1000, 
                   easing: method, 
                   complete: callback});
}

Or, try adding an "end request" event handler with .add_endRequest():

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InitialiseSettings)

Edit:

It would be a better idea for you to move your code from document.ready into InitialiseSettings(), and to then register it as a pageLoaded event handler.

Code Example

 Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(InitialiseSettings)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...