According to an answer here, I can prevent a button from submitting the form by setting its type value to "Button", like so in HTML:
<button type="button">Cancel changes</button>
...but how can I do this in C#? I am creating my controls dynamically, something like this (pseudocode, as I'm away from my IDE):
button btn = new Button
{
CSS = "bla"
}
btn.Type = "Button"; // <- something like this?
Use HtmlButton instead of Button if you want the "HTML button tag"
var btn = new HtmlButton();
btn.Attributes["class"] = "bla";
btn.Attributes["type"] = "button";
Button renders <input type="submit" />
and Button.UseSubmitBehavior renders <input type="button" />
.
HtmlButton will render <button type="YOUR_DEFINITION"></button>
.