2013-08-01 54 views
1
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

在表“Modality_Master”中没有记录,其中字段“Modality_ID”等于下拉列表“ddlModalityList”的选定值。这与隐藏的领域无关。 –

+0

无论在数据库中,我都会得到timeSlot值,但是当我在客户端读取时,它会给出默认值 – John

+0

您说当您查看页面的HTML源代码时,您会看到隐藏字段中的值不同于5吗? –

回答

0

write hidTimeSlot.Value = Convert.ToString(APP_TIME_SLOT); 在if语句中...