Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm having two buttons and one button is hidden. Now when I click the visible button I need to do two things

1.Open Iframe.

2.Automatically make the 2nd Button(Hidden)to be clicked.

When the second button is clicked I need to display the message on top of the IFrame which I have mentioned as function showStickySuccessToast()

Now I am able to open IFrame but I'm unable to make the Hidden button clicked automatically.

This is what I'm having:

      <script type="text/javascript">
       $(document).ready(function(){
        $("#<%=Button1.ClientID%>").click(function(event){
            $('#<%=TextBox1.ClientID%>').change(function () {
                $('#various3').attr('href', $(this).val());
            });
    });
       function showStickySuccessToast() {
        $().toastmessage('showToast', {
            text: 'Finished Processing!',
            sticky: false,
            position: 'middle-center',
            type: 'success',
            closeText: '',
            close: function () {

            }
        });
    }
    }) 
    </script>

Here are my two buttons how I'm working with:

<a id="various3" href="#"><asp:Button ID="Button1" 
runat="server" Text="Button" OnClientClick="Button2_Click"/></a>

<asp:Button ID="Button2" 
runat="server" Text="Button" Visible="False" OnClick="Button2_Click"/>

And in the button2_Click event:

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
       System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "showStickySuccessToast();", True)
    End Sub
share|improve this question
Any reason you couldn't use UpdatePanels? – Tim Nov 21 '11 at 19:17
I haven't tried yet with the update panels just I was trying with simple way to acheive this and further I'm planning to use the update panels and Is it good to use here in this application?May be I need most of your suggestions to make my application to work in a better way. – coder Nov 21 '11 at 19:26

1 Answer

up vote 2 down vote accepted

Put this inside the click event for your first (visible) button:

$("#<%=Button1.ClientID%>").click(function(event){
       $('#<%=TextBox1.ClientID%>').change(function () {
             $('#various3').attr('href', $(this).val()); 
       });
       $("#<%=Button2.ClientID%>").click();
});
share|improve this answer
First thanks for the reply and If I do this It gives me error as server tag is not well formed. – coder Nov 21 '11 at 17:53
That is formed the same as your other click event (just with a different ID). Maybe rebuild? I'm not sure why that would cause an error. – Nate B Nov 21 '11 at 17:55
I updated to make it more clear what I meant. – Nate B Nov 21 '11 at 17:58
@ Nate-Thanks I rectified my error and thanks for solving out my problem. – coder Nov 21 '11 at 18:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.