So, to have an answer, here's the code it's on my Page.Load (for testing)
You can see there's not value on txtBoxStarTime.Text

For my situation, I have this inside an 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 Here 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 the value from textbox in a hiddenfield, then access in codebehind... but it is still a "last-measure" solution.
The fact is, as I said - On PostBack - the "Text" value disappears. Don't know why.
Still waiting for suggestions! :)