adsense

Wednesday, May 22, 2019

Visual Studio compilation issue "Attempted to access an unloaded AppDomain"

When trying to compile  the project you might encounter following error.

Attempted to access an unloaded AppDomain

Follow these steps to solve this issue.
  • Delete all the temporary files.
  • Restart Visual studio.
  • Clean your project solution.
  • Rebuild  and run the project .


Cheers
Samitha

Monday, May 6, 2019

Preventing multiple button clicks

There are scenarios when we need to disable a button to prevent multiple form submits. There can be many other ways, but following one tested and working for me.
Even though it is a kind of hack, it the easy way to achieve what needs to be happened

HTML

<asp:Button ID="btnSave" class="btn btn-sm" runat="server" Text="Save"  OnClientClick="DisableBtn(this);"  UseSubmitBehavior="false" />

JavaScript

<script type="text/javascript">

 function DisableBtn(btn) {
    btn.setAttribute('disabled', 'disabled');
   
    btn.click();

  }

</script >

Regards,
Samitha

Wednesday, May 1, 2019

jQuery working with paste

Following jQuery code can be used to catch the paste on an input and do some manupulation to the data pasted.

<script type="javascript">
   function pageLoad(){ //or you can use DOM Ready
 
       $('textarea').bind('paste', function () {
               var this= $(this);
                var orig = self.val();

                setTimeout(function () {//to chech the diffetence between pasted and original text
                   
                    if(this[0].value!==orig  ){
                        //more code
                    }
               });


});

  }
</script>

Cheers,
Samitha