How to create click event for navigation drop down using html helper class?

I am using MVC 5. I have created navigation drop down. This is my code:

            <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="menu">
                Report
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">

            <li class="myselector"><a href="#">a </a></li>


            <li><a href="#">b </a></li>


            </ul>
            </li>

Now I have same controller but different actions for a and for b.

How to move to another page while click a and b. Is there any click event available?

Answers:

Answer

I think it work with some js code, but you does not attach any js here. So, you need to add something to your html code for identify your links as different links. Something like this

<li class="myselector action-show-a"><a>A</a></li>
<li class="myselector action-show-b"><a>B</a></li>

Then you need to select your elements using .myselector and add to them specified action according to .action-show-a and .action-show-b. For this purpose you need to add eventlistners to onclick actions.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.