c# - Set focus to child in web user control -
i've created web user control phone number entry has 3 text boxes area-code, number, , extension. text boxes in table positioning , table inside span. in page uses control have <asp:label id="label6" runat="server" associatedcontrolid="uxphonenumber">phone</asp:label>
what want set focus area-code input when associated label clicked on. web user control focus when label clicked, or can change html in ascx works? have tried adding onfocus()
<span>
tag, , <table>
tag can use javascript set focus, event not raised. if move onfocus() event first input fires , script runs
here complete ascx code.
<%@ control language="c#" autoeventwireup="true" codebehind="phonenumber.ascx.cs" inherits="customcontrols.phonenumber" %> <span id="uxphonenumbercontrol" runat="server" style="display: inline-block;" onfocus="setinitialfocus()"> <asp:table id="uxphonenumbertable" runat="server"> <asp:tablerow runat="server"> <asp:tablecell runat="server"> <telerik:radmaskedtextbox id="uxareacode" runat="server" columns="3" mask="###" cssclass="span1" skin="" maxlength="3"></telerik:radmaskedtextbox> </asp:tablecell> <asp:tablecell runat="server"> <telerik:radmaskedtextbox id="uxphonenumber" runat="server" mask="###-####" skin="" columns="10" cssclass="input-mini" maxlength="8"></telerik:radmaskedtextbox> </asp:tablecell> <asp:tablecell runat="server"> <asp:label id="uxextensionlabel" runat="server" text="ext." associatedcontrolid="uxextension" cssclass="controls-label"></asp:label> </asp:tablecell> <asp:tablecell runat="server"> <telerik:radmaskedtextbox id="uxextension" runat="server" columns="5" mask="#####" skin="" cssclass="span1"></telerik:radmaskedtextbox> </asp:tablecell> </asp:tablerow> </asp:table> <asp:hiddenfield id="uxphoneentity" runat="server" /> </span>
try attaching jquery click event span , setting focus input, this:
$(document).ready(function(){ $('#uxphonenumbercontrol').on('click',function(){ $("#inputid").focus(); }); });
note: have put general name of inputid
in focus()
call, because not able tell id or class using uniquely identify area code input control want set focus towards.
Comments
Post a Comment