简体   繁体   中英

value not persist in hidden field

   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 code

$("#contentPlaceHolderMain_btnFixAppointment").live('click', function (e)
{
  alert(document.getElementById('<%=hidTimeSlot.ClientID %>').value)
}

// i have to read timeslot value in client side. but always getting me default value that is 5 i dont know whats wrong with my code.

write hidTimeSlot.Value = Convert.ToString(APP_TIME_SLOT); inside the if statement...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM