Click here to Skip to main content
15,908,842 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<cc1:CustomImageButton id="SoDtilButton" runat="server"
                                                                                                        ImageUrl="img/CM_b2_detail.gif"
                                                                                                        AlternateText="詳細"
                                                                                                        CommandName="Dtil"
                                                                                                        ClientFocusScript="defaultFunctionKeyBody">
                                                                                                    </cc1:CustomImageButton>




I created the button like this. I want to focus this button after I click this.



Thanks.
Posted
Updated 20-Aug-15 6:38am
v3
Comments
Andy Lanng 20-Aug-15 4:21am    
"I want to focus this button after I click that"
If "this" is the button above, what is "that"?
Jip2Lay 20-Aug-15 4:25am    
sorry for my bad english, now I did correction,thank you.
Andy Lanng 20-Aug-15 4:32am    
Oh, ok.
Usually when you click a button, it will keep focus unless either you change the focus or the page reloads. Is the page reloading?
Sergey Alexandrovich Kryukov 20-Aug-15 12:25pm    
In wider sense of the word "click" (usually used in terminology related to "click event handling"), this is not exactly so. You can use the "accelerator" key, then the button won't be focused. The whole idea to enforce focus is bad.
Anyway, I answered the question, please see.
—SA
Sanket Saxena 20-Aug-15 4:37am    
still confusing on which button click?

1 solution

Please see my comment to the question, in response to the comment by Andy Lanng, as well as his comment itself. Here is the whole thing: your button will be focused in most cases. But if it won't, it means that the user does not want to focus it. You just should not do anything about it. It's really bad to enforce focus without a purpose.
However, you can always use JavaScript focus method: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900