disable double Click on Web Page

Hi Friend ,.
    Some time we face a problem like when we click on the server side button twice or more time ,it call a button event more then one time for single calling .some time it makes problem in our logic .so we need a solution code which hold the page till the server respond the single request .
Here i am placing a code which is useful in this case.

<script type="text/javascript">
        function pageLoad(sender, args) {
            var rm = Sys.WebForms.PageRequestManager.getInstance();
            rm.add_initializeRequest(initializeRequest);
            rm.add_endRequest(endRequest);
        }
        function initializeRequest(sender, args) {
            //Disable button to prevent double submit
            var btn = $get(args._postBackElement.id);
            if (btn) {
                btn.disabled = true;
                if (btn.className == 'button')
                    btn.className = 'buttonDisabled';
            }
        }
        function endRequest(sender, args) {
            //Re-enable button

            var btn = $get(sender._postBackSettings.sourceElement.id);
            if (btn) {
                btn.disabled = false;
                if (btn.className == 'buttonDisabled')
                    btn.className = 'button';
            }
        }
</script>
Hope this will help you

Rajesh

0 comments:

How to Create log file using C#

Hi friends,
Here is the C# function used in the creation of the Log files. You can use this Code to maintain the Error Log file into your project .
Here is the method,

 public void CreateLogFile(String logMsg)
    {
        FileStream lofFile;
        lofFile = new FileStream("BackUpLogFile" + DateTime.Today.ToString("ddMMyyyy") + ".txt", FileMode.Append); //this will add the Date time details in the log file
        TextWriter txtWriter = new StreamWriter(lofFile);//write the containts
        txtWriter .WriteLine("Log:" + DateTime.Now + ":- " + logMsg);
        txtWriter .Close();
    }

Hope this will help you ...
Regards
Rajesh

0 comments: