Bootstrap stops Accessing an Input after Setting Runat="Server" ASP.net C #

2

I have a input :

<input type="text" class="form-control pull-right" id="txtRangoFecha" runat="server">

When I put Runat="Server" to this object jQuery , it stops accessing and the calendar never leaves again, and the whole design of Bootstrap disappears, but if I do not put this, I can not use the control of the server side "ASP.NET" in C # .

What can I do? I need the graphic calendar, I tried with the one of "ASP.NET" but the design is not very good like that of the Bootstrap .

    
asked by Elvin Acevedo 11.11.2016 в 20:44
source

2 answers

2

In your javascript change to this:

$('#<%=txtRangoFecha.ClientID%>')

It happens that the IDs in webforms change according to where they are (referring to the Master Page and its sections)

    
answered by 11.11.2016 / 21:15
source
1

The option to use $('#<%=txtRangoFecha.ClientID%>') has the disadvantage that you can only use it from .aspx files, but you can not do it from .js files for example

In my opinion, it is much cleaner to access the element through .css selectors or add own attributes to the html element that allow you to access the control. Look at the own added attribute clientId (it could be any):

<input type="text" class="form-control pull-right" id="txtRangoFecha" clientId = "txtRangoFecha" runat="server">

Afterwards with jquery you can select the input through the own attribute.

$("input[clientId='txtRangoFecha']")

Here is a answer complete with all the options available.

    
answered by 17.11.2016 в 19:20