Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one,

I am using bootstrap button loading option in my project,

In this project i have used there are two buttons one is HTML control and the other is ASP control,
The ASP control is
XML
<asp:LinkButton ID="btnDownloadEntries" runat="Server" Text="Add" Height="35px"
                                        CssClass="btn" OnClick="btnDownloadEntries_Click" > Download </asp:LinkButton>


and the HTML control is
XML
<button class="btn btn-info ladda-button" id="btnDownloads" data-style="zoom-in" onclick="javascript:CallCodeBehind()" ><span class="ladda-label">Download</span>
                        </button>


i have used btnDownloadEntries_Click event to download some data from device to datatbasse,

I could not use bootstrap button loading option to that asp control,
so i decided to use html control for the bootstrap button loading(progress) option,
in the click event of this html control i called btnDownloadEntries_Click,(ie ASP control),
it works fine but i dont know how to set the time for button loading progress, because the button loading is suddenly closed before the completion of data download from the device to DB.

Below is the javascript i called while button (html button click)
<script type="text/javascript">

function CallCodeBehind()
{

document.getElementById('<%= btnDownloadEntries.ClientID %>').click();
alert('');

// return false;
}
// Bind normal buttons

Ladda.bind( 'div:not(.progress-demo) button', { timeout: 2000 } );

// Bind progress buttons and simulate loading progress
Ladda.bind( '.progress-demo button', {
callback: function( instance ) {

var progress = 0;
var interval = setInterval( function() {
progress = Math.min( progress + Math.random() * 0.1, 1);
instance.setProgress( progress );

if( progress === 1 ) {
instance.stop();
clearInterval( interval );
}
}, 200 );
}
} );



</script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36251023-1']);
_gaq.push(['_setDomainName', 'jqueryscript.net']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

and the code behind i called is

C#
protected void btnDownloadEntries_Click(object sender, EventArgs e)
    {
        //ShowError2(true, "alert alert-danger", "");
        if (ddlDownloadEntries.SelectedItem.Text.Trim() != "Select Device")
        {

            try
            {
                string filePath = AppDomain.CurrentDomain.BaseDirectory.ToString() + "CSV\\Test.CSV";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                    File.Create(filePath).Close();
                }
                StringBuilder sb = new StringBuilder();
                sb = bio.AttendanceLog(ddlDownloadEntries.SelectedItem.Text.Trim());

                if (sb.Length != 0)
                {
                    File.AppendAllText(filePath, sb.ToString());
                    if (ImportLog())
                    {
                        string SP = "CALL `sp_GetLatest_Log`()";
                        int result = mc.ExecuteNonQuery(SP);
                        ShowError2(true, "alert alert-success", result + " Record(s) are Downloaded Successfully");
                    }
                    else
                        ShowError2(true, "alert alert-danger", "File Importing Failed");

                }
                else
                {
                    if (bio.Msg == "")
                        ShowError2(true, "alert alert-danger", "No Records for Processing");

                    else
                        ShowError2(true, "alert alert-danger", bio.Msg);
                }
            }
            catch (Exception ex)
            {
                ShowError2(true, "alert alert-danger", ex.Message);
            }
        }
    }
    private bool ImportLog()
    {
        string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "CSV\\Test.CSV";
        path = path.Replace(@"\", @"//");
        string query = "TRUNCATE TABLE tbl_attendancelog_tmp;LOAD DATA LOCAL INFILE '" + path + "' INTO TABLE tbl_attendancelog_tmp FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' (IpAddress,EnrollNumber,dwVerifyMode,dwInOutMode,dwWorkcode,Record_Date,dwYear,dwMonth,dwDay,Record_Time,dwHour,dwMinute,dwSecond,Access_Time)";
        int result = mc.ExecuteNonQuery(query);
        if (result > 0) return true;
        else return false;
    }


Here i want to know how to pass the time to this button loading (Bootstrap) so that that the button will be changed as loading until the c# function is executed.

Please help me in this , Thanks in advance..
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900