本文介绍了在pageload之前调用javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在pageload上有一个函数,我使用标签中的值(日和月)。我从sql查询中的js函数获取这些标签的值,但这些值在页面加载后的页面加载coz js运行时保持为空。有办法解决这个问题吗?任何帮助将不胜感激。

谢谢



js功能如下:

I have a function on pageload where I am using values from labels(day and month). I am getting values of these labels from a js function in a sql query but these values remain empty at the time of pageload coz js runs after pageload. Is there a way to resolve this?? Any help would be greatly appreciated.
Thanks

js function is a follows:

<script type="text/javascript">
    function time() {
        var currentTime = new Date();
        var day = currentTime.getDate();
        var month = currentTime.getMonth() + 1;
        document.getElementById("day").value = day;
        document.getElementById("month").value = month;
    }
</script>





Sql查询如下:





Sql query is as follows:

"select logo,companyname from logos where status='True' AND type='Birthdays' AND day='"+day.Text.ToString()+"' AND month='"+month.Text.ToString()+"'"

推荐答案


protected void Page_Load(object sender, EventArgs e)
    {
        var query = "select logo,companyname from logos where status='True' AND type='Birthdays' AND day='" + DateTime.Now.Day.ToString() + "' AND month='" + DateTime.Now.Month.ToString() + "'";
    }


这篇关于在pageload之前调用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 06:46