how to set value in asp.net control via javascript?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nirmalsingh
    New Member
    • Sep 2006
    • 218

    how to set value in asp.net control via javascript?

    hai all,
    i have a text box(asp.net control) named as txtName,

    i set a data to it using javascript as:

    [HTML]document.getEle mentById('<%=tx tName.ClientID% >').value="Nirm al";[/HTML]

    it works fine,

    but when i set property to txtName as visible="false"

    i cant set data to it.

    plz help me to overcome this. thank you.
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi there,

    Setting the visible property to false will stop the server from displaying the control on the client. As Javascript is a client side language it will therefore not be able to see the control.

    If you want to be able to set the control's value with javascript I suggest you try to either:
    1. Use Javascript to hide the control
    2. Set the colour of the control to the same as the background of it's container thus rendering it effectively invisble.
    Obviously the first option is preferable.

    Hope this helps,

    Dr B

    Comment

    Working...