开发者

call document.ready function after page postback

I have the following function on my page. This function will select all the checkbox on Repeater control. It works great when page is 1st time loaded. But the function didn't call/work when I reload or refresh the page or select different criteria on the page (at postback). So as soon as I have postback on this, the document.ready() function doesn't call anymore. How can still call loadChkCtrls() function when page is at postback?

<script type="text/javascript">
         $(document).ready(function() {
             checked = false;
             alert("test");
             loadChkCtrls();
 开发者_JAVA技巧            return;

         });

     function loadChkCtrls() {
         alert("test3");
         $("span.chkEachRow input").attr('checked', false);

         $("#chkAllRows").click(function() {
             alert("test1");
             if (checked == false) {
                 checked = true
             }
             else {
                 checked = false
             }
             $("span.chkEachRow input").attr('checked', checked);
             return;
         });
     }

</script>      


I got it working. The following code worked for me.

ScriptManager.RegisterStartupScript(Me, Page.GetType(), "scriptKey", "loadChkCtrls();", True)

Thanks, Annie

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜