I am trying to place a button on a webform in which when I click on it a submenu will appear giving me other options to navigate on my application. Is there any way to do it? Can you place sample code please.
Asked
Active
Viewed 2,781 times
-3
-
No. You could either use a `DropDownList` or try to achieve this with JavaScript. – Linus Caldwell May 22 '13 at 18:01
-
Can you do it: Yes. It's going to take a bit of javascript. When the button is pressed you will need to show a div that contains this submenu you want. Hook into the buttons onclick handler and, because this is asp.net, make sure that it `returns false;` so that the form isn't submitted. – NotMe May 22 '13 at 18:06
-
1You should post some code of what you've tried already. It's not good [Stack Overflow](http://stackoverflow.com/faq#dontask) practice to post questions without first trying or researching yourself. – ckpepper02 May 22 '13 at 18:17
2 Answers
0
try this: http://jsfiddle.net/MXkCb/
<input type="button" value="show more options" class="showmore"/>
<div><ul>
<li>option 1</li>
<li>option 2</li>
<li>option 3</li>
<li>option 4</li>
</ul></div>
$('.showmore').on('click', function(){
$('div').show("slow");
});

user1
- 1,063
- 1
- 8
- 28
0
In your view, try this:
@ { var cultureItems = LocOptions.Value.SupportedUICultures .Select(c => new SelectListItem { Value = c.Name, Text = c.TwoLetterISOLanguageName }) .ToList();
}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle waves-effect waves-light" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown title
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
@foreach (var culture in cultureItems)
{
<form id="selectLanguage" asp-controller="Home"
asp-action="SetLanguage" asp-route-returnUrl="@Context.Request.Path"
method="post" class="form-horizontal" role="form">
<input class="dropdown-item waves-effect waves-light" type="submit" name="culture" value="@culture.Value" />
</form>
}
</div>
</li>

nurmanbetov
- 102
- 9