Click here to Skip to main content
15,893,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,
I had created a web user control for drop down checked box list, following is code
C#
<asp:TextBox ID="txtCombo" runat="server" ReadOnly="true" CssClass="DropDownCss" BackColor="#EEEEEE" Width="225" Height="25" ></asp:TextBox>
<cc1:PopupControlExtender ID="PopupControlExtender111"  runat="server" 
    TargetControlID="txtCombo" PopupControlID="Panel111" Position="Bottom" >
</cc1:PopupControlExtender>

<input type="hidden" name="hidVal" id="hidVal" runat="server" />

<asp:Panel ID="Panel111" runat="server"  Width="230" BackColor="#EEEEEE" BorderColor="Gray" BorderWidth="1">
    
    <asp:CheckBoxList ID="chkList" 
        runat="server" 
        Height="150" onclick="CheckItem(this)"         
        >                                                                                                                                                                        
    </asp:CheckBoxList>
 
</asp:Panel>


In this I am calling a javascript function to get current selected list item.

JavaScript
function CheckItem(checkBoxList) {
       //code here
       
    }


when I am keeping this control is a chile element on aspx page, it is failing to load the javascript function.
In browser showing message as "Uncaught ReferenceError: CheckItem is not defined"

If control is having only one parent control then working fine.

How to overcome this issue.

Thanks in advance.

-Avinash
Posted
Comments
TheKarateKid 21-Feb-15 19:37pm    
For me it is working
I have ASPX with following script:
<script type="text/javascript" language="javascript">
function CheckItem(checkBoxList) {
//code here
alert('Hi');
}

and markup
<uc1:Parent2 ID="Parent21" runat="server" />

Hierarchy is like this
ASPX
- Parent 2 (UserControl)
- Test (UserControls) with checkbox list





</script>

and

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