开发者

How to use javascript to get an ASP.NET's Textbox Control's Value

开发者 https://www.devze.com 2022-12-17 18:57 出处:网络
Suppose I have 开发者_如何学运维an ASP.NET Text Box as Below : <asp:TextBox ID=\"txtQuantity\" runat=\"server\" Text=\"0\"></asp:TextBox>

Suppose I have 开发者_如何学运维an ASP.NET Text Box as Below :

<asp:TextBox ID="txtQuantity" runat="server" Text="0"></asp:TextBox>

I want to get this box's current value in javascript. How can I access this element?


use the clientID property

document.getElementByID('<%=txtQuantity.ClientID %>')

More information here

you can also use find

Quoted from the above link:

Additionaly the ClientID is used in ASP.NET Ajax as the unique identifier of client-side controls. Thus the following JavaScript statement is commonly used:

var control = $find("<%= MyControl1.ClientID %>");


You can get the client side ID using txtQuantity.ClientID.

0

精彩评论

暂无评论...
验证码 换一张
取 消