最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to change text property of asp.net textbox with javascript - Stack Overflow

programmeradmin1浏览0评论

I have a textbox that I want to change text property of it with javascript, but I can't do.

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

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

I have a textbox that I want to change text property of it with javascript, but I can't do.

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

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

Share Improve this question edited Dec 4, 2009 at 7:32 David Hedlund 130k33 gold badges204 silver badges223 bronze badges asked Dec 4, 2009 at 7:29 maveramavera 3,2417 gold badges47 silver badges60 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 8

Try this :

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

NOTE : By the way if your hdnAdresIndex is a server control, you should use control's ClientID property to get client side id :

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

use value instead of innerText

also, if you're not in asp.net mvc, the ID of the control is probably not what you expect. Look into the myTextBox.ClientID property on the asp.net control.

发布评论

评论列表(0)

  1. 暂无评论