Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint <button> elements perform an unwanted reload of the page

I have an aspx page on my SharePoint site, which I have included tags. For some reason, every button on the page will reload the page when clicked. Even the buttons with no attributes (id, class, etc) or functions will reload the page when clicked. How can I fix this issue? I can't even see what's going on in the debugger because I'm not calling any reload functions, so I have no idea where to place a breakpoint.

Thank you in advance for your help, I really appreciate it.

like image 671
user1226409 Avatar asked Dec 06 '22 15:12

user1226409


1 Answers

The problem here is with the <button> tag. Its default behavior is to act as a submit button unless otherwise declared and will reload.

To keep your <button> tag, add type='button' to the button element. I think that prevents the reload.

Or you could go with the ole <input> tag with a type='button'. That keeps the reload from happening as well.

Or some other html element with an onclick event will work too.

like image 200
Josey Avatar answered Dec 25 '22 17:12

Josey