<asp:Button runat="server" id="LoginBtn" type="Button" Text="Login" OnClientClick="document.getElementById('jsLogin').style.display='inline-grid'" />
As the title states, the above line of code is what is present in my Master.master page.
But when I run the debugger (visual studio 2017), chrome and the application run the button with a postback, and when I examine the element, it's still showing
<input type="submit" name="ctl00$LoginBtn" value="Login" onclick="document.getElementById('jsLogin').style.display='inline-grid';" id="LoginBtn">
I have zero clue what to do.
UPDATE 7/19/2018 (20 minutes later)
reverted to an older source control:
the only change was near the top of the master.master:
<html lang="en-us">
<form runat="server">
<head runat="server">
<asp:scriptmanager runat="server"></asp:scriptmanager>
instead of
<html lang="en-us">
<head runat="server">
<form runat="server">
<asp:scriptmanager runat="server"></asp:scriptmanager>
and on the Default.aspx page this line:
<%@ MasterType VirtualPath="~/Master.master" %>
is not commented out.
Literally nothing else changed O.o Someone who knows more about ASP.Net than me please clue me in.
Update 7/20/2018 - 18:39 gmt
Reproduced the root cause.
<asp:textbox>
was set to required. I removed the required and created a custom javascript function. Apparently there is a problem with FormsAuthentication.Signout() when you try to clear authentication on hidden forms that have required set.
<script>
function validation() {
var username = document.getElementById('uNameLogin').value;
var password = document.getElementById('uPasswordLogin').value;
if (username == null || password == null || username == "" || password == "")
{
document.getElementById('uNameLogin').value = "User Name & Password Required!";
return false;
}
}
</script>
after adding that, to prevent the post back I followed the suggestion of adding return false to the OnClientClick javascript:
OnClientClick="javascript:document.getElementById('jsLogin').style.display='inline-grid'; return false;"
and it resolved the problem of the Login button causing postback.
<input>?<input>tied to an AJAX call to the code-behind instead.