I have a user control, a dropdown list, that’s comprised of many component controls.
The main HtmlInputText will post back on an enter but on loss of focus it doesn’t and I need that to update other controls.
I added an onblur function, and it gets called, but I only want to postback when the element getting focus isn’t part of the user control.
How do I determine what is selected and if it’s a child of the control?
Markup:
<%@ Register Assembly="MultiDropDown" Namespace="MultiDropDownLib" TagPrefix="MultiDropDownLib" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<table style="width: 328px">
<tr>
<td>
ProductClass
</td>
<td>
<MultiDropDownLib:MultiDropDown ID="MultiDropDown1" runat="server" TextBoxClass="textboxDD"
PostOnBlur="true" />
</td>
...
And in the control:
if (PostOnBlur)
{
txtItemList.Attributes.Add("onblur", string.Format("PostBack();", this.ClientID));
}
In the PostBack I want to determine what has focus and if it’s part of the control. The original control came from: http://www.codeproject.com/Articles/219977/MultiDropDown-A-multiple-selection-Dropdown-contro
This is a way to do it with javascript and jQuery:
Just replace
$WebUserControl1with the name of your user control. This could also be Dynamic if you want to. Basically all of the children of the usercontrol will contain the name of their parent because WebUserControls inherit from TemplateControl which implements the INamingContainer interface.Good luck.