Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Suggest me a way to remove code repetation

$
0
0

I'm integrating JQuery functionality into my ASP.net application. And some wrote some functionality with JQuery. Along with that I'm coding ASP.Net by integrating AJAX control toolkit, to make my JQuery work with updatepanel, i wrapped my code in requestmanger endrequest as (sample) following.

<script type="text/javascript">
var requestManager = Sys.WebForms.PageRequestManager.getInstance();
        requestManager.add_endRequest(function () {
               var listboxdiv = $("div.listBoxdiv");$(".spanclose").on("click", function () {
                    listboxdiv.fadeOut();
                });
}); </script>

I'm wrapping this in script block after <form> tag declaration.

To make this functionality work on page load, i'm wrapping same code in <head> as following

<script type="text/javascript">       $(function () {
            var listboxdiv = $("div.listBoxdiv");$(".spanclose").on("click", function () {
                listboxdiv.fadeOut();
            });                      
        });</script>

I know, i'm repeating code. but i sent to production and everyone happy

but i want to know how to achieve this with out repeating

Thanking you in advance.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>