You must Sign In to post a response.

How to invoke Anchor tag click event without clicking in asp.net

Hi,

I am working on a asp.net application. In this I want a javascript function which have to invoke Anchor tag click event without clicking in asp.net.

If anyone have any idea to do this please reply me.


Thanks in advance.


Comments

Author: Madhu04 Dec 2009 Member Level: Gold   Points : 2

What the action you want to do. and in which scnario you want to raise the anchor click event. Without clicking to raise the click event is not the right way.
You tell clearly the requirement then can get the way.

Author: Rajapandian04 Dec 2009 Member Level: Gold   Points : 2

Hi,

Try below code:

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

Author: NekkantiDivya04 Dec 2009 Member Level: Gold   Points : 2

Hi Rajapandian,


Thank you for your quick reply.
I tried you code but I am not getting click() function in aspx page Javascript.

If you have any other solution please reply me.

Thanks in advance

Author: NekkantiDivya04 Dec 2009 Member Level: Gold   Points : 2

Hi Madhu,

Actually I have to call javascript function in aspx page from a silverlight page. In this Javasript function I need to navigate to a page in lightbox style. I have code for displaying a page in light box style only on clicking a anchor tag. So for navigating to a page and displaying it in a light box style I want a Javascript function which will invoke anchor tag click event without clicking

If you have any solution to solve this please reply me.

Thanks in advance

Author: Rajapandian04 Dec 2009 Member Level: Gold   Points : 2

Hi,

click will not be displayed in Intellisense. But if you write the code, it will work.

I tested this code from my end.

Author: Madhu04 Dec 2009 Member Level: Gold   Points : 2

Divya,

You are showing the Lightbox for what. In all the cases you are showing the popup or only in a particualr case.
Confirm the occassion you need to show the page in light box.

I think if a user is trying for some action , if does not allow for that then need to show another page. When ever that action fails call thos JS method.

Author: NekkantiDivya04 Dec 2009 Member Level: Gold   Points : 2

Hi Rajapandian,

Thank you for your reply.
I tried it but it is giving error. Below is the error.
document.getElementById("linkid1").click();

Error:
System.InvalidOperationException

Can you please share your code with me so that I will check it.
Please reply me how to solve this.


Thanks in advance

Author: Rajapandian04 Dec 2009 Member Level: Gold   Points : 3

function ClickAnc()
{
document.getElementById('anchor').click();
}


Anchor

Author: NekkantiDivya04 Dec 2009 Member Level: Gold   Points : 2

Thank you Rajapandian

Now it is working. Here problem is with the Quotation marks.

document.getElementById('anchor').click(); is working but I tried with
document.getElementById("anchor").click(); so it didn't worked.

Now it is fne

Author: NekkantiDivya04 Dec 2009 Member Level: Gold   Points : 2

Hi Rajapandian,

Again I have a problem with this. That is it(Javascript) is working in IE but it is not working in Mozilla Firefox.
Please reply me how to solve this.

Thanks in advance.

Author: Rajapandian07 Dec 2009 Member Level: Gold   Points : 2

Hi,

Try below code

document.getElementById('anchor').onclick();


Sign In to post your comments