Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Using the answer in my previous question, "ModalPopupExtender: Popup Closes After TextChanged Method of Textbox FIres", I was able to get the popup to work as intended as a stand-alone form including the addition of a third button to the "modal popup":
<asp:Button ID="btnReset" runat="server" Text="Standard" OnClick="btnReset_Click"/>

However when I add the relative code an existing website, I receive the following error:

"Error: Unable to get property 'click' of undefined or null reference".

The website uses a master page and the modal popup panel is within two panels, all of which is surrounded by an update panel on a tab panel. What would prevent execution of the onclick code of the new button? Is there another method to executing the code?

XML
I only have javascript for the Ok and Cancel button of the popup (none for the Reset):

    <script type="text/javascript">
        function onOk() {
            document.getElementById('btnOk').click();
        }

        function onCancel() {
            document.getElementById('btnCancelRates').click();

        }
    </script>

How would I call the onclick code for the new button?
Posted
Updated 12-Jul-13 6:27am
v2
Comments
ZurdoDev 12-Jul-13 11:58am    
You need to post the relevant JavaScript code. The error is saying that the ID of what you are trying to reference is not valid. Being that it is now on a master page just view source and you'll see that extra information gets added to its ID so that .Net makes sure it is unique.
FabeCode 12-Jul-13 12:10pm    
I only have javascript for the Ok and Cancel new button of the popup (none for the Reset):

<script type="text/javascript">
function onOk() {
document.getElementById('btnOk').click();
}

function onCancel() {
document.getElementById('btnCancelRates').click();

}
</script>

I would I call the onclick code for the new button?
ZurdoDev 12-Jul-13 12:17pm    
OK. So, put a breakpoint and find out what is happening. Also, use the improve question link and post this code as part of your question. It will be easier to follow.
FabeCode 12-Jul-13 13:02pm    
Where should I put a breakpoint?
ZurdoDev 12-Jul-13 13:10pm    
I'm confused. You have 2 lines of code. One for clicking OK and one for clicking Cancel. Which button are you clicking?

1 solution

Found the solution. I removed the JS for the OnCancel. removed the CancelControlID and OnCancelScroipt from the ModalPopupExtendedupdates, and used OnClick events for Reset and Cancel buttons. The Ok button uses the JS,

XML
<asp:Panel ID="pnlCustCharge" Width="275px" runat="server" Style="display: none">
    <table style="margin-left: 75px">
        <tr>
            <td>
                <asp:Button ID="OkButton" runat="server" Text="OK" Style="display: none"/>
                <asp:Button ID="btnOk" runat="server" Text="OK"
                     OnClick="btnOk_Click"/>
            </td>
            <td style="width: 10px">
            </td>
            <td>
                <asp:Button ID="CancelButton" runat="server" Text="Reset"
                OnClick="btnCancelRates_Click" />
            </td>
            <td style="width: 10px">
            </td>
            <td>
                <asp:Button ID="ResetButton" runat="server" Text="Standard"
                    OnClick="btnReset_Click" />
            </td>
        </tr>
    </table>
</asp:Panel>
<br />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCustCharges"
    PopupControlID="pnlCustCharge" BackgroundCssClass="modalBackground" DropShadow="true"
    EnableViewState="true" OkControlID="OkButton" OnOkScript="onOk()"
    />
 
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