So, to get the answer, here is the code that it is on my .Load page (for testing)
You can see that there is no value on txtBoxStarTime.Text

In my situation, I have this inside the update panel:
<asp:TextBox runat="server" ID="txtBoxStartTime" TextMode="Time" Width="102px"></asp:TextBox> <asp:TextBox runat="server" ID="txtBoxEndTime" TextMode="Time" Width="102px"></asp:TextBox> <asp:Button CssClass="positive" ID="btnOtherSendRequest" runat="server" Text=" Send Request" ToolTip="The selected request would be sent to X" OnClick="btnOtherSendRequest_Click"/>
This is the code in VB.NET:
Protected Sub btnOtherSendRequest_Click(sender As Object, e As EventArgs) Try lblSubmitted.Text = "" lblValidateNotInfo.Text = "" hdnRequestType.Value = "OTH" Dim messageSuccessful As String = "Thank you for submitting your Request(s)!" Dim messageUnSuccessful As String = "The Request was not submitted due to some errors. Please 'Go Back' and re-send!" Select Case ddlRequest.SelectedValue Case "18" ' Schedule Update Call If Not (txtBoxStartDate.Text.Length > 0 And txtBoxEndDate.Text.Length > 0 And IsDate(txtBoxStartDate.Text) And IsDate(txtBoxEndDate.Text)) Then ' AI - if dates are in invalid format ScriptManager.RegisterStartupScript(Me, Me.GetType, "AlertScript", "alert ('Please make sure the dates are in a valid format!');", True) Exit Sub ElseIf Not CDate(txtBoxStartDate.Text).CompareTo(Date.Now) > 0 Then ' AI - Start Date must be greater than today. ScriptManager.RegisterStartupScript(Me, Me.GetType, "AlertScript", "alert ('""Start"" date must be a future date!');", True) Exit Sub ElseIf Not CDate(txtBoxEndDate.Text).CompareTo(CDate(txtBoxStartDate.Text)) >= 0 Then ' AI - Start Date must be greater than today. ScriptManager.RegisterStartupScript(Me, Me.GetType, "AlertScript", "alert ('""End"" date must be the same as the ""Start"" date or a date after the ""Start"" date!');", True) Exit Sub ElseIf CDate(txtBoxStartDate.Text).DayOfWeek = DayOfWeek.Saturday Or CDate(txtBoxStartDate.Text).DayOfWeek = DayOfWeek.Sunday Or CDate(txtBoxEndDate.Text).DayOfWeek = DayOfWeek.Saturday Or CDate(txtBoxEndDate.Text).DayOfWeek = DayOfWeek.Sunday Then ScriptManager.RegisterStartupScript(Me, Me.GetType, "AlertScript", "alert ('Weekends excluded!');", True) Exit Sub Else lblSubmitted.Text = messageSuccessful End If Case "19" ' Request Training Call Case "20" ' Request Call from Cust. Service Case "21" ' Other Request If txtBoxOther.Text <> "" Then lblSubmitted.Text = messageSuccessful Else lblSubmitted.Text = messageUnSuccessful ScriptManager.RegisterStartupScript(Me, Me.GetType, "AlertScript", "alert ('Please enter your request into the textarea first!');", True) txtBoxOther.Focus() Exit Sub End If End Select Call sendRequest() Call JSEffect(True) Catch ex As Exception lblMessage.Text = "Error when taking the request to be inserted - " & ex.Message Finally hlServCenterPend.Text = "Pending Requests (" & getServCenterStatus("PEND").ToString & ")" hlServCenterComp.Text = "Completed Requests (" & getServCenterStatus("COMP").ToString & ")" End Try End Sub
And so I got the error:
Public Sub sendRequest(Optional pid As Integer = 0, Optional claim As Integer = 0, Optional insured As Integer = 0) Dim req As New cls_services.request Try req.clinicID = CInt(MyMod.FetchStoredData("ClinicID")) req.pid = pid req.type = CInt(ddlRequest.SelectedValue) Select Case req.type Case 1, 11, 12, 13, 14 req.status = "COMP" Case Else req.status = "PEND" End Select req.claimID = claim req.insuranceID = insured req.dueDate = req.getDueDate(req.type) req.other = Trim(txtBoxOther.Text) Select Case req.type Case 18 req.fromDate = CDate(txtBoxStartDate.Text) req.fromTime = CDate(txtBoxStartTime.Text)//ERROR HERE! - EXCEPTION req.toDate = CDate(txtBoxEndDate.Text) req.toTime = CDate(txtBoxEndTime.Text) End Select req.fax = Trim(txtFaxTreatmentRecords.Text) req.createUser = Request.ServerVariables("AUTH_USER")
My solution here is trying to store a value from a text field in a hidden field, then access codebehind ... but it is still a "last resort" solution.
The fact is that, as I said, in PostBack, the value "Text" disappears. I do not know why.
Still waiting for suggestions! :)