Pergunta

I have a grid within a form-tag. Each row in the grid has two buttons, wich of one is of type submit. I thought that only the submit button would fire of the form submission. But all buttons actually post the form.

Why is that? What's the reason to have the type="submit" tag if it's not taken into account? And how could I solve this? I need multiple buttons in some of my grids.

    @using (Html.BeginForm("Action", "Controller"))
    {
           Html.RenderPartial("_TestGrid");
    }

And the buttons in this grid:

grid.Column(format: @<text><button>Do something</button></text>), 
grid.Column(format: @<text><button type="submit" value="1">Do something else</button></text>
Foi útil?

Solução

Use <input/> insted of <button>

grid.Column(format: @<text><input type="button" value="Somthing"/></text>), 
grid.Column(format: @<text><<input type="submit" value="Save"/></text>)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top