0

How can I make a link (anchor) fire a button onclick code while the link is sitting in an Web User Control and the button is sitting in the main .aspx page.

What I'm trying to accomplish this is to be to export a gridview to excel from a toolbar/utility bar that is sitting in the Web User Control.

Any help will really appreciate it.

2 Answers 2

1
<a href="#" onclick="document.getElementById('B').click();">hello</a>
<input type="button" id="B" onclick="alert('HA!');" />
Sign up to request clarification or add additional context in comments.

4 Comments

Will this work if the button is sitting on a different page than the link?
I'm not sure what you mean by a "different page" - you only get one page at a time.
I have an .aspx page and an .ascx control, the link is on the .ascx control and the button I want to execute is on the .aspx page. Will the script be able to find the button?
Stop thinking in .NET -- look at the OUTPUT (view source). This is your page. aspx and ascx build the page on the server and give the output to the browser. Everything in JavaScript happens in the browser and has little to do with your .NET code. Pretend it's dumb HTML.
0

Create a server side hyperlink and add Button1_click() to hyperlink click event.

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.