views:

44

answers:

1

I have a textbox which can be left blank or contain a date. If the textbox has a date I want the 2nd textbox's value to be set to the value of a session variable. I need this to happen before the update sql is performed on postback.

This is the code I have. But the textbox is coming back as nothing. Whether it has a value in it or not.

If IsPostBack Then
        Dim Dev_Doc_Date As TextBox
        Dev_Doc_Date = FindControl("Dev_Document_Date")

        If Not Dev_Doc_Date Is Nothing Then
            Dim Dev_Doc_Date_Value As String
            If Not String.IsNullOrEmpty(Dev_Doc_Date.Text) Then
                Dev_Doc_Date_Value = Dev_Doc_Date.Text
            Else
                Dev_Doc_Date_Value = String.Empty

            End If
        End If
End If
A: 

I took a different route. I passed the session variable using javascript. If the length of the textbox (date) was equal to 8 (validation ensures that it is) then set the value of the 2nd textbox to the session variable.

function Uploader(field, e)
{
    var inputName = field.name;
    var len = document.getElementById(inputName).value.length;

    if (len == 8)
    {
        window.document.form1.FormView1$Dev_Doc_Updater.value = "<%= Session("PIN") %>";
    }   
}
Anthony