The "#location" notation is to redirect inside the same page. If you want to go to another page this is "page.aspx#location". You'll need also <a name="location">Target</a> in the destination page.
A small remark. IMHO never try to do something another way because what should work doesn't. Else you could end up in doing things in a more complex way (here using javascript etc...) when a basic link could just work perfectly fine.
Always try first to understand what happens exactly and then you can change your mind but at least based on a firm understanding of the situation rather than just entering now forever into your home using the window because your door "doesn't work".
Anchors <a>, don’t fire a click event unless a href is defined. It’s common in this case to use just a #. href=“#”. You can also use the jquery on() to get the click at the body, but use a selector to check it happened in the anchor.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
implemented the code but did not worked nothing happens when i click.
My Requriement in Dashbaord click should redirect to sic_dashbaord.aspx and other inks which i mentioned earlier in the post will redirect to same page
implemented the code but did not worked nothing happens when i click.
The code is work fine in my side. Can you provide the complete code?
nagapavanich
My Requriement in Dashbaord click should redirect to sic_dashbaord.aspx and other inks which i mentioned earlier in the post will redirect to same page
Do you want to redirect li to the same page? if so, you can try what Bruce said, using href to redirect.
Best regards,
Sam
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
This is just what you asked for. What follows # is the location inside a page. As you give no page indication, it is searched inside the current page.
It seems you want instead something such as (assuming the other page is in the same folder) to tell both which page should be loaded "as usual" and then which location you want to reach inside that page.
Member
5 Points
77 Posts
click event of anchor tag does not work
Jan 31, 2020 01:18 PM|nagapavanich|LINK
Hi all,
I have
now I want a click event on Dashboard when i click it should redirect to my page.aspx
but href does not work so tried click event of the anchor tag
but event not firing
All-Star
53021 Points
23607 Posts
Re: click event of anchor tag does not work
Jan 31, 2020 01:53 PM|mgebhard|LINK
If you make the dropdown clickable then you will not be able to select the menu items. Why not add the path to href attributes in the menu items?
All-Star
48510 Points
18071 Posts
Re: click event of anchor tag does not work
Jan 31, 2020 02:06 PM|PatriceSc|LINK
Hi,
The "#location" notation is to redirect inside the same page. If you want to go to another page this is "page.aspx#location". You'll need also <a name="location">Target</a> in the destination page.
A small remark. IMHO never try to do something another way because what should work doesn't. Else you could end up in doing things in a more complex way (here using javascript etc...) when a basic link could just work perfectly fine.
Always try first to understand what happens exactly and then you can change your mind but at least based on a firm understanding of the situation rather than just entering now forever into your home using the window because your door "doesn't work".
All-Star
58174 Points
15650 Posts
Re: click event of anchor tag does not work
Feb 02, 2020 06:36 PM|bruce (sqlwork.com)|LINK
Anchors <a>, don’t fire a click event unless a href is defined. It’s common in this case to use just a #. href=“#”. You can also use the jquery on() to get the click at the body, but use a selector to check it happened in the anchor.
Contributor
3370 Points
1409 Posts
Re: click event of anchor tag does not work
Feb 03, 2020 04:01 AM|samwu|LINK
Hi nagapavanich,
I tested your code and found some question.
It should be jq instead of j.
and If you want to fire Dashboard click event, you can try the following code:
<script type="text/javascript"> var jq = jQuery.noConflict(); jq(document).ready(function () { jq("#dash").click(function () { alert("click"); }); // $('#dash').trigger('click'); }); </script>
Best regards,
Sam
Member
5 Points
77 Posts
Re: click event of anchor tag does not work
Feb 03, 2020 09:37 AM|nagapavanich|LINK
Hi mgebhard,
tried this already but it does work
Member
5 Points
77 Posts
Re: click event of anchor tag does not work
Feb 03, 2020 09:40 AM|nagapavanich|LINK
Hu samwu,
implemented the code but did not worked nothing happens when i click.
My Requriement in Dashbaord click should redirect to sic_dashbaord.aspx and other inks which i mentioned earlier in the post will redirect to same page
sic_dashbaord.aspx but different div s
All-Star
58174 Points
15650 Posts
Re: click event of anchor tag does not work
Feb 05, 2020 04:55 PM|bruce (sqlwork.com)|LINK
why use on click? just set the href
note: you should use the server to generate the url in razor (don't remember webforms) it is:
<a class="nav-link dropdown-toggle" href="@Url.Content("~/sic_dashbaord.aspx")" data-toggle="dropdown" id="dash">Dashboard
Contributor
3370 Points
1409 Posts
Re: click event of anchor tag does not work
Feb 06, 2020 02:54 AM|samwu|LINK
Hi nagapavanich,
The code is work fine in my side. Can you provide the complete code?
Do you want to redirect li to the same page? if so, you can try what Bruce said, using href to redirect.
Best regards,
Sam
All-Star
48510 Points
18071 Posts
Re: click event of anchor tag does not work
Feb 06, 2020 08:41 AM|PatriceSc|LINK
This is just what you asked for. What follows # is the location inside a page. As you give no page indication, it is searched inside the current page.
It seems you want instead something such as (assuming the other page is in the same folder) to tell both which page should be loaded "as usual" and then which location you want to reach inside that page.