Forums » .NET » ASP.NET »

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


Posted Date: 04 Dec 2009      Posted By:: NekkantiDivya Profile photo    Member Level: Gold    Member Rank: 914     Points: 1   Responses: 11



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.




Responses

#450265    Author: Madhu      Member Level: Gold      Member Rank: 613     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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.


 
#450268    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

Try below code:

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

Regards,
Rajapandian


 
#450272    Author: NekkantiDivya      Member Level: Gold      Member Rank: 914     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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





 
#450274    Author: NekkantiDivya      Member Level: Gold      Member Rank: 914     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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


 
#450275    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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.

Regards,
Rajapandian


 
#450277    Author: Madhu      Member Level: Gold      Member Rank: 613     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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.


 
#450293    Author: NekkantiDivya      Member Level: Gold      Member Rank: 914     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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


 
#450296    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 04/Dec/2009   Rating: 3 out of 53 out of 53 out of 5     Points: 3

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


<a onclick="alert('anchor clicked');" id="anchor">Anchor</a>
<asp:Button ID="btn1" runat="server" Text="Click Anchor" OnClientClick="ClickAnc(); return false;" />

Regards,
Rajapandian


 
#450365    Author: NekkantiDivya      Member Level: Gold      Member Rank: 914     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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


 
#450383    Author: NekkantiDivya      Member Level: Gold      Member Rank: 914     Date: 04/Dec/2009   Rating: 2 out of 52 out of 5     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.


 
#450890    Author: Rajapandian      Member Level: Gold      Member Rank: 238     Date: 07/Dec/2009   Rating: 2 out of 52 out of 5     Points: 2

Hi,

Try below code

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

Regards,
Rajapandian


 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Return to Discussion Forum
Start new thread

Subscribe to Subscribers
Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John

Online Members

vivek
More...
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India