HLRosenberger
asked on
Call the click event of a ASP.NET button from another form
I want to Call the click event of a ASP.NET button from another form. How can I do this? Can I use JavaScript?
This was suggested to me. Does this make sense?
"Probably the simplest way of triggering the AJAX refresh across windows is to put a refresh button on the calling page, hide it with Javascript, and then call its click() method from the other page by using that same opener property to access the first page. You might need the document.getElementById('r efreshButt onName'); function to find the refresh button."
This was suggested to me. Does this make sense?
"Probably the simplest way of triggering the AJAX refresh across windows is to put a refresh button on the calling page, hide it with Javascript, and then call its click() method from the other page by using that same opener property to access the first page. You might need the document.getElementById('r
document.getElementById('btnId').click();
from the child window (triggering click on parent window):
opener.document.getElement ById('btnI d').click( );
from the parent window, if you have opened a window like this:
var wnd = window.open('url');
then use:
wnd.document.getElementByI d('btnId') .click();
opener.document.getElement
from the parent window, if you have opened a window like this:
var wnd = window.open('url');
then use:
wnd.document.getElementByI
ASKER
The child window is a popup and I display it using window.showModalDialog.
I tried opener.document.getElement ById('btnI d').click( ) and wnd.document.getElementByI d('btnId') .click() and neither seems to work, unless I am doing something wrong. There is an accept button on the popup that does self.close(). When accept is click, this is where I want to trigger a refresh button click on the page from which i opened the popup?
Question: How does it know to look for the button on the parent page and not on the popup?
I tried opener.document.getElement
Question: How does it know to look for the button on the parent page and not on the popup?
window.opener.document.getElementById('btnId').click()
should work when called from the popup before calling self.close
ASKER
I tried this. it does not seem to work. The button ID. How does the codue know which page the button is on?
well when you say window.opener it means the parent window. try adding a function in the parent and calling that.
e.g.
e.g.
parent page:
function testCall() {
alert('comes here');
}
popup page:
window.opener.testCall();
ASKER
I found my problem - I need to reference the ASP button like this:
var RefreshButton= window.document.getElement ById("<%= Unidentified_DocumentsRefr eshButton. ClientID %>");
What's the deal with the <%= %> syntax? What does that tell the JavaScript interpreter? Do you know if I always need this syntax?
var RefreshButton= window.document.getElement
What's the deal with the <%= %> syntax? What does that tell the JavaScript interpreter? Do you know if I always need this syntax?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the explanation!
btnSave_Click(sender, e);