I am using hash to open mybootstrap modal. When I type Home/Index#mymodal
in the URL manually , it works. The modal is displayed automatically. The problem is when I want to submit the form. Below is my code. I try to direct the form to Home/Index#mymmodal
. But the URL shows Home/Index%23mymmodal?inputName=john
. When I try to change the URL manually Home/Index?inputName=john#mymmodal
, it works. So I try to append the #mymmodal
at the end of the current the URL. I used this but it does not work.
$('.ajaxLink').click(function (e) {
location.hash = this.id; // get the clicked link id
e.preventDefault(); // cancel navigation
// get content with Ajax...
});
This is my code:
<form method="get" action="@Url.Action("Index#mymodal", "Home")">
<input type="text" name="inputName" Class="form-control">
</form>
<Button type="submit" value="search">Search</Button>