Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Date mask input into a textbox .NET control in a gridview itemtemplate

Posted on 2010-11-20
1
Medium Priority
?
2,401 Views
Last Modified: 2012-06-21
Hi,
i have a gridview with 3 itemtemplates where i put a textbox , one of this textbox i want to put a Date mask(dd/MM/yyyy) how i do this in jquery ?! the jquery not find the control, because is into a gridview . my code is attach with this post !!!
<asp:UpdatePanel ID="UpdatePanelDependentes" runat="server" UpdateMode="Conditional" >
                             <ContentTemplate> 		
                                <asp:TextBox ID="txtNumDependentes" width="40px" runat="server" AutoPostBack="true" MaxLength="2" TabIndex="15" ontextchanged="txtNumDependentes_TextChanged"></asp:TextBox>
                                <img id="erroNumDependentes" src="../../imgs/erro_small.gif" style="visibility:hidden;" width="18" height="17" alt="" />
                                <h1>Dados sobre os dependentes</h1>
                                 <asp:GridView ID="grdDependentes" runat="server" AutoGenerateColumns="False" 
                                     Width="750px" Visible="True" 
                                     EmptyDataText="Não existe Dependentes listados !" 
                                     onrowdatabound="grdDependentes_RowDataBound">
                                     <Columns>
                                         <asp:TemplateField HeaderText="Nome">
                                             <ItemTemplate>
                                                 <asp:TextBox ID="txtNomeDependente" runat="server" Width="300px"></asp:TextBox>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Data Nascimento">
                                             <ItemTemplate> 
                                             <script type="text/javascript">
                                                 var grdDependentes = document.getElementById('<%=grdDependentes.ClientID %>').getElementsByTagName('input');
                                                 $('#<%=grdDependentes.ClientID %> input[type=Text]').mask("99/99/9999");                                                 
                                                
                                             </script>                                            
                                                 <asp:TextBox ID="txtDataNascimentoDependente" class="Mask" alt="Mask" runat="server" Width="80px"></asp:TextBox>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Sexo">
                                             <ItemTemplate>
                                                <asp:RadioButtonList ID="rdlSexoDependente" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" TabIndex="2">
                                                    <asp:ListItem Value="Masculino">Masculino</asp:ListItem>
                                                    <asp:ListItem Value="Feminino">Feminino</asp:ListItem>                            
                                                </asp:RadioButtonList>
                                             </ItemTemplate>
                                         </asp:TemplateField>
                                         <asp:TemplateField HeaderText="Estado Civil">
                                            <ItemTemplate>
                                                <asp:SqlDataSource ID="DTSESTADOCIVIL" runat="server" ConnectionString="<% $ConnectionStrings:csPLHP %>" SelectCommand="Select est_id,est_civil From estado_civil"></asp:SqlDataSource>
                                                <asp:DropDownList ID="ddlEstadoCivilDependente" runat="server"  DataSourceID="DTSESTADOCIVIL"
                                                    AppendDataBoundItems="True" DataTextField="est_civil" DataValueField="est_id" 
                                                    Width="180px" TabIndex="6">
                                                    <asp:ListItem Selected="True" Value="-1">Selecione</asp:ListItem>
                                                </asp:DropDownList>
                                            </ItemTemplate>                                         
                                         </asp:TemplateField>
                                     </Columns>
                                 </asp:GridView>
                                <br />
                            </ContentTemplate>
                        </asp:UpdatePanel>

Open in new window

0
Comment
Question by:Igor Nesralla
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 34179816
What about using a dedicated class instead ID of the control

$('.someClass').mask("99/99/9999");  
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question