简体   繁体   中英

C# Set Focus To 3rd Party Controls

I have a 3rd party drop down treeview in my asp.net C# code

<ct:ASDropDownTreeView ID="astvMyTree" runat="server"... />

I'd like to set focus on it in the code behind. Obviously the C# control.Focus() only works on Windows controls. I've tried javascript

 ScriptManager.RegisterStartupScript(Page, this.GetType(), "control_focus", "ASDropDownTreeView.focus();", true);

but it doesn't work either. Is there a way I'm supposed to declare the 3rd party controls in javascript or does it also only work on html and windows controls?

You need to find the control name on the client side somehow. ASP.NET controls have ClientID property that tell you what will be control name on client side. If your controls have something similar then you can use this.

Other option is to run the page, view html source and see client name.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM