<asp:TextBox />
, then it is rather difficult to predict what the ID of the corresponding <input type=”text” />
element will be. While quite often you need to know the ID of the rendered item. But it looks something like this - ctl00_contentBody_txtStreet.
There are several ways to overcome this difficulty, which are described here . All of them either require writing bulky constructions, or even creating their own controls. But there is another very simple way to get a client ID.CssClass
attribute in ASP.NET server controls, which correspond to the class attribute HTML tags. Surely, many have worked with jQuery and know the selector that allows you to get elements with the specified class name. So why not combine all this?<asp:TextBox ID="txtStreet" runat="server" CssClass="txtStreet" />
alert($('.txtStreet').val());
alert($('input.txtStreet').val());
Source: https://habr.com/ru/post/53347/
All Articles