如何保持JavaScript的UpdatePanel的局部回传后 [英] how to keep javascripts after UpdatePanel partial postback

查看:138
本文介绍了如何保持JavaScript的UpdatePanel的局部回传后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有很多code,所以我想在不久的话解释的问题。我有一个母版页,这包括对JavaScript文件的所有引用并使用该母版页的页面。我使用的更新面板在我的页面和更新面板里面也有一些形式包括一个具有回传功能(即DropDownList的)。问题是,当状态变化和局部回传发生时,其具有一定的能力,并因为这些Javascript角的影响的形式,则失去所有功能。任何帮助将是AP preciated。

There is a lot of code so I want to explain the issue shortly in words. I have a Master page, that includes all references to javascript files and have the pages that use the master page. I use update panel in my pages and inside the update panel there are some forms including that one-has postback capability(ie dropdownlist). The problem is when the state changes and a partial postback occurs, the forms which has some capabilities and effects because of those javascripts, then lose all the functionality. Any help would be appreciated.

推荐答案

这是由于部分后回来,你需要重新初始化的JavaScript更新后面板。这是一个普通的例子。

This is because after the partial post back with the Update panel you need to re-initialize the javascript. Here is a general example

<script type="text/javascript"> 
   // if you use jQuery, you can load them when dom is read.
   $(document).ready(function () {
       var prm = Sys.WebForms.PageRequestManager.getInstance();    
       prm.add_initializeRequest(InitializeRequest);
       prm.add_endRequest(EndRequest);

       // Place here the first init
    });        

    function InitializeRequest(sender, args) {
    }

    function EndRequest(sender, args) {
       // after update occur on UpdatePanel re-init what you need

    }
</script> 

相对的问题:结果
<一href=\"http://stackoverflow.com/questions/3341623/asp-net-updatepanel-in-gridview-jquery-datepicker/3341741#3341741\">Asp.Net在UpdatePanel的GridView的jQuery的DatePicker的结果
<一href=\"http://stackoverflow.com/questions/10041169/how-to-get-id-update-panel-that-initial-a-request-in-javascript/10041337#10041337\">How获得初始的JavaScript请求ID更新面板

在网4你也可以简单使用页面加载的功能,类似于在onload功能,但由asp.net处理,被称为第一页负荷,也被称为AJAX每次更新后。

After the net 4 you can also simple use the pageLoad function, is similar to the OnLoad function, but is handled by asp.net and is called on the first page load, but also called after each ajax update.

function pageLoad()
{
    // init here your javascript
    // This is called when the page load first time
    //  and called again each time you have an Update inside an UpdatePanel
}

参考: http://msdn.microsoft .COM / EN-US /库/ bb386417(v = VS.100)的.aspx

这篇关于如何保持JavaScript的UpdatePanel的局部回传后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆