I have 2 forms in my myPage.chtml page as follows:
@using (Html.BeginForm("Tests1", "Test", FormMethod.Post, new { id = "FormSearch1" }))
{
<input type ="submit" value="Filter1 " id="submit" />
}
and another form as follows:
@using (Html.BeginForm("Tests2", "Test", FormMethod.Post, new { id = "FormSearch2" }))
{
<input type ="submit" value="Filter2 " id="submit" />
}
However, I am having the error message and it`s not working upin clicking the submit buttons. What am I missing?
Warning 2 Another object on this page already uses ID ‘submit’.
In your example, you have two
<input>elements that have the sameid="submit"attribute.idshould be unique on each HTML page. To solve the problem, either remove theidattribute completely (if it is not actually used), or use different values.If you need to have these submit buttons to have the same name but different values (considering the different Actions and ids submit in your example, I doubt that), you could try to use
<input type="submit" value="Filter1" name="submit"/>and<input type="submit" value="Filter2" name="submit"/>instead.