关于按钮加载计时器设置 [英] Regarding button loading timer settings

查看:94
本文介绍了关于按钮加载计时器设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在我的项目中使用bootstrap按钮加载选项,



在这个项目我用过有两个按钮,一个是HTML控件,另一个是ASP控件,

ASP控件是

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

<asp:LinkButton ID="btnDownloadEntries" runat="Server" Text="Add" Height="35px"

                                        CssClass="btn" OnClick="btnDownloadEntries_Click" > Download </asp:LinkButton>





并且HTML控件是



and the HTML control is

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





i使用btnDownloadEntries_Click事件将一些数据从设备下载到datatbasse,



我无法使用bootstrap按钮加载选项到那个asp控件,

所以我决定使用html控件来执行bootstrap按钮加载(进度)选项,
$ b这个html控件的click事件中的$ b我叫做btnDownloadEntries_Click,(即ASP控件),

它运行正常,但我不知道如何设置按钮加载进度的时间,因为在完成从设备到数据库的数据下载之前突然关闭按钮加载。



下面是我调用的javascript按钮(单击html按钮)

< script type =text / javascript>



函数CallCodeBehind()

{



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

alert('');



//返回false;

}

//绑定正常按钮



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



//绑定进度按钮并模拟加载进度

Ladda.bind('。progress_demo button',{

回调:函数(例子){



var progress = 0;

var interval = setInterval(function(){

进度= Math.min(进度+ Math.random()* 0.1,1);

instance.setProgress(进度);



如果(进度=== 1){

instance.stop();

clearInterval(间隔);

}

},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>



我调用的代码是





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

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;
    }





在这里,我想知道如何将时间传递给此按钮加载(Bootstrap),以便按钮将被更改为加载,直到执行c#功能。



请帮助我,提前谢谢..



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..

推荐答案

这篇关于关于按钮加载计时器设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆