Search code examples
asp.netjavascripttextfieldmodalpopup

Textfield value empty when I fill it with javascript


I am using modalpopup to enter some value in a textfield. After the value is selected in the modalpopup view, the modalpopup is closed and the value takes the appropriate value. Even if the value is displayed in the textfield, the textfield1.text returns an empty string. When I see the source code (html), I see that even the textfield isn't displaying anything; it hasn't really had this value input, because the appropriate html input field hasn't got a value yet.

This is the code I use to fill this textfield:

function CloseRequestModal(s)
    {
        document.getElementById('<%=txtRequest.ClientID%>').value = s;

        var mpu = $find('<%=ModalPopupExtender3.ClientID%>');
        mpu.hide();
    }

Please help.


Solution

  • i fixed this problem in an alternate way.

    even if the value is there (in the textfield), none of the events is fired, to let know the browser / compilator that the value really exists.

    so i decided, despite editing the value of the textfield, i store this value in the session too. in this case, the value is displayed for user needed in the interface, and on the other hand i use the value that i stored in the session.