Note these two functions are the same, just named differently:
abc.js ===>
function displayConfirmCreateDestinationOrOriginModal() {
$('[id$=confirmCreateDestinationOrOriginModal]').css('display', 'block');
}
function toggleConfirmCreateDestinationOrOriginModal() {
$('[id$=confirmCreateDestinationOrOriginModal]').css('display', 'block');
}
def.aspx ===>
DOESN’T WORK:
<button
id="a"
type="button"
onclick="toggleConfirmCreateDestinationOrOriginModal()">Create New</button>
DOES WORK:
<button
id="a"
type="button"
onclick="displayConfirmCreateDestinationOrOriginModal()">Create New</button>
Likewise, if I use asp:Button, same issue
DOESN’T WORK:
<asp:Button
id="a"
type="button"
text="Create New"
runat="server"
onclick="toggleConfirmCreateDestinationOrOriginModal()" />
DOES WORK:
<asp:Button
id="a"
type="button"
text="Create New"
runat="server"
onclick="displayConfirmCreateDestinationOrOriginModal()" />
The JavaScript code should run in both cases, making a modal show.
I even did a clean and rebuild before each attempt.
I added all this code, so the problem isn’t to do with something else: it’s all new code and only the display* method works. This behaviour is making me ask: is toggle* a special word in JavaScript or asp?
I’m pretty new to asp and wanted to understand what is going on, as this sort of bug could cause me a lot of wasted time in the future, should such errors be for a reason that I don’t understand.