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

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

programmeradmin0浏览0评论

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?

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?

Share Improve this question edited Jun 20, 2013 at 10:38 MD Sayem Ahmed asked Jan 20, 2010 at 14:44 MD Sayem AhmedMD Sayem Ahmed 29.2k27 gold badges115 silver badges181 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 12

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)

  1. 暂无评论