How to change text property of asp.net text field using javascript

I have a text box that I want to change for it using javascript, but I cannot do this.

My sample code is below. Can anyone say what is wrong? Thanks...

function openAdresYeni(p) {
        document.getElementById('hdnAdresIndex').innerText = p;         
        }
    }

+3
source share
2 answers

Try the following:

function openAdresYeni(p) { 
    document.getElementById('hdnAdresIndex').value = p;
}

NOTE. . By the way, if your hdnAdresIndexis a server control, you should use the ClientID property to get the client side identifier:

function openAdresYeni(p) { 
    document.getElementById('<%= hdnAdresIndex.ClientID %>').value = p;
}
+8
source

use valueinsteadinnerText

, asp.net mvc, , , , . myTextBox.ClientID asp.net.

+5

Source: https://habr.com/ru/post/1724707/


All Articles