Santosh Kumar

Santosh Kumar

  • NA
  • 126
  • 60.3k

How to increase session timeout of hidden field value

Aug 10 2015 8:41 AM
Hi,
 
 
I am binding the gridview values to the hiddenfield and calling the hidden field values on button clik event by spliting the values of hidden field based on ~(for rows) and ^(columns). This is working fine but, when after the session timeout, the values of the hidden field is getting lost and "object reference not found" exception is occurring. Please give me the solution of increasing session for hidden field.
 
 
function updateValues1() {   
var grdProjectEmpUpdDetails = document.getElementById("<%=grdProjectEmpUpdDetails.ClientID %>");
var hdnUpdateData = document.getElementById("<%=hdnUpdateData.ClientID %>");
hdnUpdateData.value = '';
var checkempid = '';
for (var j = 1; j <= grdProjectEmpUpdDetails.rows.length - 2; j++)
{ checkempid = ''; var cellCount = grdProjectEmpUpdDetails.rows[j].cells.length;
for (var i = 0; i < cellCount; i++)
]
 { if (hdnUpdateData.value == '') {
if (i == 0 || i == 1)
 { if ((grdProjectEmpUpdDetails.rows[j].cells[i].innerText) == undefined)
{ var txt = grdProjectEmpUpdDetails.rows[j].cells[i].textContent;
hdnUpdateData.value = txt;
}
else {
hdnUpdateData.value = grdProjectEmpUpdDetails.rows[j].cells[i].innerText;
}
}
else {
hdnUpdateData.value = grdProjectEmpUpdDetails.rows[j].cells[i].childNodes[0].value;
 }
}
else {
if (i == 0 || i == 1) {
if (i == 0) {
var demo = grdProjectEmpUpdDetails.rows[j].cells[i].children;
if (demo.length > 1) {
hdnUpdateData.value += grdProjectEmpUpdDetails.rows[j].cells[i].children[1].value;
 } else {
if (grdProjectEmpUpdDetails.rows[j].cells[i].innerText == undefined) {
var txt = grdProjectEmpUpdDetails.rows[j].cells[i].textContent;
 hdnUpdateData.value += txt;
}
else {
hdnUpdateData.value += grdProjectEmpUpdDetails.rows[j].cells[i].innerText;
}
}
} else {
if (grdProjectEmpUpdDetails.rows[j].cells[i].innerText == undefined) {
var txt = grdProjectEmpUpdDetails.rows[j].cells[i].textContent;
hdnUpdateData.value += '^' + txt;
} else {
hdnUpdateData.value += '^' + grdProjectEmpUpdDetails.rows[j].cells[i].innerText;
} } }
else {

if (i == 9) {
var drpDown = ''; //
if (grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName("select")) { // var dl = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName("select"); //for (var ilo = 0; ilo < dl.length; ilo++) { // if (dl[ilo].attr("disabled", "disabled")) { // dl[ilo].removeAttribute('disabled'); // } //} // for (var iilo = 0; iilo < dl.length; iilo++) { // drpDown = dl[iilo].options[dl[iilo].options.selectedIndex].value; // } // hdnUpdateData.value += '^' + drpDown; // } if (drpDown == '') { var celltxtbxrol = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName('input'); if (celltxtbxrol.length != 0) { for (var jroln = 0; jroln < celltxtbxrol.length; jroln++) { if (celltxtbxrol[jroln].type == "text") { hdnUpdateData.value += '^' + celltxtbxrol[jroln].value; } } } } else { hdnUpdateData.value += '^' + drpDown; } } else { if (i == 11) { var dropDownunit = ""; var dlunit = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName("select"); for (var ilu = 0; ilu < dlunit.length; ilu++) { dlunit[ilu].removeAttribute('disabled'); } for (var ilu = 0; ilu < dlunit.length; ilu++) { dropDownunit = dlunit[ilu].options.selectedIndex; } hdnUpdateData.value += '^' + dropDownunit; } else { if (i == 18 && i != 11) { var items = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName("a"); var filename = ""; for (var hprlnk = 0; hprlnk < items.length; hprlnk++) { if (items[hprlnk].innerText == undefined) { filename += items[hprlnk].textContent; } else { filename += items[hprlnk].innerText; } } if (filename == "") { hdnUpdateData.value += '^' + grdProjectEmpUpdDetails.rows[j].cells[i].textContent; } else { hdnUpdateData.value += '^' + filename; } } var celltxtbxadd = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName('input'); if (celltxtbxadd.length != 0) { for (jaddn = 0; jaddn < celltxtbxadd.length; jaddn++) { if (celltxtbxadd[jaddn].type == "text") { hdnUpdateData.value += '^' + celltxtbxadd[jaddn].value; } } } else { if (i == 17) { if (grdProjectEmpUpdDetails.rows[j].cells[i].innerText == undefined) { var txt = grdProjectEmpUpdDetails.rows[j].cells[i].textContent; hdnUpdateData.value += '^' + txt; } else { checkempid = grdProjectEmpUpdDetails.rows[j].cells[i].innerText hdnUpdateData.value += '^' + checkempid; } } else { var dropDown = ""; var dl = grdProjectEmpUpdDetails.rows[j].cells[i].getElementsByTagName("select"); for (var ilo = 0; ilo < dl.length; ilo++) { dl[ilo].removeAttribute('disabled'); } for (var iilo = 0; iilo < dl.length; iilo++) { dropDown = dl[iilo].options[dl[iilo].options.selectedIndex].text; } if (dropDown == "" && checkempid != '-99999') { if (grdProjectEmpUpdDetails.rows[j].cells[i].innerText == undefined) { var txt = grdProjectEmpUpdDetails.rows[j].cells[i].textContent; hdnUpdateData.value += '^' + txt; } else { checkempid = grdProjectEmpUpdDetails.rows[j].cells[i].innerText hdnUpdateData.value += '^' + checkempid; } } else { hdnUpdateData.value += '^' + dropDown; } } } } } } } }
hdnUpdateData.value += '~';


}
}



C#


public List GenerateFactTimeCardActualHoursDataFromEmpHdnField(string hdnControlData)
{
List lstempTotActualEffort = new List();
List objSearchResult = (List)Session["SearchResult"];
List dimTimeList = new List();
List dateSkPeriodToList = new List();
DimTimeService dimTimeService = new DimTimeService(this.ContextBO);
if (hdnControlData != string.Empty)
{
Userloggin = Convert.ToString(Session["UserName"]);
string[] rowData = hdnControlData.Split('~');
foreach (string row in rowData)
{
if (row != string.Empty)
{
string[] stringData = row.Split('^');
string onofsite = string.Empty;
FactTimeCardActualHoursPeriodWiseBO factTimeCardActualHoursPeriodWise = new FactTimeCardActualHoursPeriodWiseBO();

factTimeCardActualHoursPeriodWise.ProjectID = (string.IsNullOrEmpty(stringData[1]) || string.IsNullOrWhiteSpace(stringData[1])) ? 0 : Convert.ToInt32(stringData[1]);
factTimeCardActualHoursPeriodWise.EmployeeID = (string.IsNullOrEmpty(stringData[3]) || string.IsNullOrWhiteSpace(stringData[3])) ? string.Empty : Convert.ToString(stringData[3]);
if (factTimeCardActualHoursPeriodWise.EmployeeID == "-99999" || factTimeCardActualHoursPeriodWise.EmployeeID == string.Empty)
{
factTimeCardActualHoursPeriodWise.EmployeeFullName = string.Empty;
}
else
{
factTimeCardActualHoursPeriodWise.EmployeeFullName = (string.IsNullOrEmpty(stringData[4]) || string.IsNullOrWhiteSpace(stringData[4])) ? string.Empty : Convert.ToString(stringData[4]);
}
factTimeCardActualHoursPeriodWise.AmountBilled = (string.IsNullOrEmpty(stringData[16]) || string.IsNullOrWhiteSpace(stringData[16])) ? 0 : Convert.ToDecimal(stringData[16]);
factTimeCardActualHoursPeriodWise.Remarks = (string.IsNullOrEmpty(stringData[17]) || string.IsNullOrWhiteSpace(stringData[17])) ? string.Empty : stringData[17];
factTimeCardActualHoursPeriodWise.AmountTobeBilled = (string.IsNullOrEmpty(stringData[15]) || string.IsNullOrWhiteSpace(stringData[15])) ? 0 : Convert.ToDecimal(stringData[15]);
factTimeCardActualHoursPeriodWise.Rate = (string.IsNullOrEmpty(stringData[13]) || string.IsNullOrWhiteSpace(stringData[13])) ? 0 : Convert.ToDecimal(stringData[13]);
factTimeCardActualHoursPeriodWise.UnitSk = (string.IsNullOrEmpty(stringData[11]) || string.IsNullOrWhiteSpace(stringData[11])) ? 0 : Convert.ToInt32(stringData[11]);
factTimeCardActualHoursPeriodWise.Quantity = (string.IsNullOrEmpty(stringData[12]) || string.IsNullOrWhiteSpace(stringData[12])) ? 0 : Convert.ToSingle(stringData[12]);
factTimeCardActualHoursPeriodWise.ExpenseType = (string.IsNullOrEmpty(stringData[10]) || string.IsNullOrWhiteSpace(stringData[10])) ? string.Empty : Convert.ToString(stringData[10]);
factTimeCardActualHoursPeriodWise.Currency = (string.IsNullOrEmpty(stringData[14]) || string.IsNullOrWhiteSpace(stringData[14])) ? string.Empty : Convert.ToString(stringData[14]);
factTimeCardActualHoursPeriodWise.Sow = (string.IsNullOrEmpty(stringData[7]) || string.IsNullOrWhiteSpace(stringData[7])) ? string.Empty : Convert.ToString(stringData[7]);
factTimeCardActualHoursPeriodWise.PONumber = (string.IsNullOrEmpty(stringData[8]) || string.IsNullOrWhiteSpace(stringData[8])) ? string.Empty : Convert.ToString(stringData[8]);
factTimeCardActualHoursPeriodWise.EmployeeRole = (string.IsNullOrEmpty(stringData[9]) || string.IsNullOrWhiteSpace(stringData[9])) ? string.Empty : Convert.ToString(stringData[9]);
factTimeCardActualHoursPeriodWise.WorkHours = (string.IsNullOrEmpty(stringData[6]) || string.IsNullOrWhiteSpace(stringData[6])) ? string.Empty : Convert.ToString(stringData[6]);
onofsite = (string.IsNullOrEmpty(stringData[5]) || string.IsNullOrWhiteSpace(stringData[5])) ? string.Empty : Convert.ToString(stringData[5]);
if (onofsite.Trim()=="SelectShore")
{
factTimeCardActualHoursPeriodWise.OnsiteOffshore = "";
}
else
{
factTimeCardActualHoursPeriodWise.OnsiteOffshore = onofsite;
}
factTimeCardActualHoursPeriodWise.SubmittedStatus = "Submitted";
factTimeCardActualHoursPeriodWise.Attachments = string.Empty;
factTimeCardActualHoursPeriodWise.ModifiedDate = DateTime.Now;
factTimeCardActualHoursPeriodWise.CreatedDate = DateTime.Now;
string emailid = Userloggin.ToLower() + "@sonata-software.com"; ;
factTimeCardActualHoursPeriodWise.CreatedBy = emailid.Trim();
factTimeCardActualHoursPeriodWise.ModifiedBy = emailid.Trim();
foreach (var item in objSearchResult)
{
if (factTimeCardActualHoursPeriodWise.ProjectID == item.ProjectId)
{

var startDate = item.StartDate;
var EndDate = item.EndDate;


dimTimeList = dimTimeService.GetDate(startDate);
dateSkPeriodToList = dimTimeService.GetDate(EndDate);

factTimeCardActualHoursPeriodWise.DateSkPeriodFrom = Convert.ToInt32(dimTimeList[0].DateSK);

factTimeCardActualHoursPeriodWise.DateSkPeriodTo = Convert.ToInt32(dateSkPeriodToList[0].DateSK);
factTimeCardActualHoursPeriodWise.ProjectName = item.ProjectName;
factTimeCardActualHoursPeriodWise.StartDate = item.StartDate;
factTimeCardActualHoursPeriodWise.EndDate = item.EndDate;
}
}
lstempTotActualEffort.Add(factTimeCardActualHoursPeriodWise);
}
}
}
return lstempTotActualEffort;
}























 
 
 

Answers (5)