-1

Hi I am trying to call a button click function written within the c# code behind from javascript. but its not triggering the button click function. I didnt find anything suspicious in the code. Please check and let me know what is actually blocking the call. These are my code scraps.

<script  language="javascript" type="text/javascript">
        function ConfirmFuncn() {
            var Msge = document.getElementById('<%=hdnMsge.ClientID %>').value;
            if (confirm(Msge)) {
                document.getElementById('<%=hdnTestValue.ClientID %>').value = "true";
            }
            else {
                document.getElementById('<%=hdnTestValue.ClientID %>').value = "false";
            }

            document.getElementById('<%=btnSaveHidden.ClientID %>').Click();
        }
    </script>

<asp:Button ID="btnSaveHidden" runat="server" Visible="false" 
                            Text="HiddenSaveButton" onclick="btnSaveHidden_Click"
                             />

Here it does not call btnSaveHidden_Click. Javascript function ConfirmFuncn is calling properly, because i am getting the message value I set to hidden field. But btnSaveHidden_Click is not triggering. Why?

1

2 Answers 2

1

it wont work when:

Visible="False"

incited of hidden the button by it self just hide in indies a hidden div :

you can hide your button with hidden div

<div style="display: none;">    
    <asp:Button ID="btnSaveHidden" runat="server" Visible="false" 
                Text="HiddenSaveButton" onclick="btnSaveHidden_Click" />
</div>
Sign up to request clarification or add additional context in comments.

Comments

1

Use style="display: none;" instead of Visible="false"

<asp:Button ID="btnSaveHidden" runat="server" style="display: none;"     
            Text="HiddenSaveButton" onclick="btnSaveHidden_Click" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.