int APP_TIME_SLOT = 5;
protected void Page_Load(object sender, EventArgs e)
{
SetTimeSlot();
}
private void SetTimeSlot()
{
SqlCommand objSqlCommand = null;
strSQL = @"SELECT Time_Slot";
objSqlCommand = new SqlCommand(strSQL, SqlConnectionObject);
string timeSlot = Convert.ToString(objSqlCommand.ExecuteScalar(objSqlCommand));
if(!string.IsNullOrEmpty(timeSlot))
{
APP_TIME_SLOT = Convert.ToInt32(timeSlot);
}
//SET TIMESLOT.READ ON CLIENT SIDE.
hidTimeSlot.Value = Convert.ToString(APP_TIME_SLOT);
}
// javascript代码
$("#contentPlaceHolderMain_btnFixAppointment").live('click', function (e)
{
alert(document.getElementById('<%=hidTimeSlot.ClientID %>').value)
}
//我必须在客户端读取时隙值。 但总是得到我的默认值是5 我不知道我的代码有什么问题。
答案 0 :(得分:0)
写hidTimeSlot.Value = Convert.ToString(APP_TIME_SLOT); 在if语句中......