如何在ASP.NET中禁用/隐藏/ visibility = false按钮 [英] How to disable / hide / visibility = false button in ASP.NET
本文介绍了如何在ASP.NET中禁用/隐藏/ visibility = false按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点击后,24小时后隐藏或禁用按钮。
我点击按钮时已将信息保存在用户数据库中。但现在我想在24小时后隐藏该按钮。
检查我的代码。 Addhour上的红线错误。
我尝试过:
once clicked, hide or disable the button after 24 hour.
i have saved information in database of user when he clicked the button. but now i want to hide that button after 24 hours.
check my code. red line error on Addhour.
What I have tried:
SqlCommand cmd;
SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Imdad Hussain\documents\visual studio 2012\Projects\FlowerTestPhase\FlowerTestPhase\App_Data\Database1.mdf;Integrated Security=True");
String emaill = "";
String OrdrTime = "";
String querry = "select * from OrderVarify where Uemail='" + Session["Email"].ToString() + "'";
cmd = new SqlCommand(querry, conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
emaill = dr["Uemail"].ToString();
OrdrTime = dr["OrderTime"].ToString();
}
if (emaill.Equals(Session["Email"].ToString()) && DateTime.Now >= OrdrTime.AddHours(24))
{ //
}
推荐答案
你好,
我一眼就看到你试图将一个名为AddHours()的方法调用到一个字符串类型变量。 字符串没有这样的方法;您的变量 OrdrTime 必须是 DateTime 类型,因为所述类型具有AddHours()方法。
Hi there,
At a glance I see that you are trying to invoke a method called AddHours() to a string type variable. Strings do not have such method; your variable OrdrTime has to be of type DateTime, for said type does have the AddHours() method.
//String OrdrTime = "";
DateTime aver = new DateTime();
....
OrdrTime = Convert.ToDateTime(dr["OrderTime"]);
//or, it depends on what data type you 'select *' is returning
OrdrTime = (DateTime)dr["OrderTime"];
...
if(.... OrdrTime.AddHours(24))
{
yourButton.Visible = false;
}
希望这会有所帮助。
这篇关于如何在ASP.NET中禁用/隐藏/ visibility = false按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文