I want to focus on a user control but it is giving me errors
function getFocus() {
document.getElementById('<%myUserControl.ClientID%>').focus()
}
<a href.... onclick="getFocus()>Click</a>
How can i do this?
Thank you
Replace this:
document.getElementById('<%myUserControl.ClientID%>').focus()
with this:
document.getElementById('<%= myUserControl.ClientID%>').focus()
<%=myUserControl.ClientID%> missing "="
I am not sure of that which component you want to focus on. If you want to focus on the "Rates". Based on the code you posted on the other question, I suggest you change your code to.
<a id="p2" href="#" runat="server">Rates</a>
: remove the lable and then add href to do what you want to do here. and then in your javascript: document.getElementById("<%=p2.ClientID%>").focus();
then you can get Rates focus.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.