1

I have an iframe in asp.net, using c# . When the iframe with a story ends, I want to fire a button in parrent window via java script.

The iframe window has its own html file and js file. when the iframe come to an end of story in the js file run

    case "ClosePlayer":    
    trig();    
    break;   

then I call another js file with a simple function

    function trig()
   {    
    //$('#<%= SubmitButton.ClientID %>').click();
    //document.getElementById('<%= SubmitButton.ClientID %>').click();
    document.getElementById("SubmitButton").click();
   // alert("javascript here");

    }

in the main window in asp.net I have this button

<asp:Button ID="btnProceedToNextTab" runat="server" Text="Proceed" OnClick="btnProceedToNextTab_Click"  />

and I want to trigger this with another button via javascript, so the code behind of the function btnProceedToNextTab_Click(); run

<asp:Button ID="SubmitButton" runat="server" Text="Button" OnClientClick="trig();" />

Can anyone help me? I tried to use jquery, but nothing fires the button. The alert messages show ok, but the button is never clicked.

1
  • i also have use from child window : parent.document.getElementById("SubmitButton").click(); Commented Mar 18, 2014 at 14:49

4 Answers 4

1

Try something like this in your parent window:

$("#iFrame").contents().find("#ButtonInIframeWindow").live('click',function(){


$('#submitButtonInParentWindow').click();


});
Sign up to request clarification or add additional context in comments.

Comments

0

this is false:

document.getElementById("SubmitButton").click(); 

you have to use jQuery selector like this:

$("#SubmitButon").click();

Comments

0

Can you try this...

You can invoke your click function in javascript function..

document.getElementById('btnProceedToNextTab').click();

Please feel free to mark as answer if it satisfies....

Comments

0

ok found it.

from child (iframe window) call a js file with trig();

function trig()

{

var proceedButton = parent.$('[id$="btnProceedToNextTab"]');
proceedButton.trigger('click');
return false;

}

and in parent window:

<asp:Button ID="btnProceedToNextTab" runat="server" Text="Proceed" Style="display:none;" OnClick="btnProceedToNextTab_Click"  />

works for me! thanks.

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.