I'm trying to add a CSS class to the Control that will get the focus, once a page is rendered. While the SetFocus() method of the Page class lets me set the Control, there is no corresponding GetFocus() method.
According to the .Net sources, the information is stored in the private member _focusedControl of the Page class. The property FocusedControl is marked internal.
Is there a way to get the value of the private member or internal property by using Reflection?
Any help would be greatly appreciated.
Clarification: Here is why I want to add a CssClass server side: I'm trying to apply the following JQuery script, that changes the background of the focused element:
$(document).ready(function() {
var elements = jQuery("textarea, select, multi-select, :text, :password, :file");
elements.bind
(
'focus',
function() {
jQuery(this).addClass('highlightinput');
}
);
elements.bind
(
'blur',
function() {
jQuery(this).removeClass('highlightinput');
}
);
})
This works fine as long as I don't specifically set a focused control in my aspx.vb. If I do set a focused control (I think due to a timing issue), the focus is set before my handlers are attached to the input fields and thus, the input is not highlighted. So my approach would be to add the highlightinput class to the focused control before rendering the page.