Apostrophe breaking Controller call from Button
Posted: February 14th, 2024, 12:24 pm
I had a registration page on a 5.1 MVC Client I was working on.
Regular Request:
<button type="button" value="Approve" validationgroup="" disableonclick="No" iseof="False" isdefault="false" isenabled="True" title="" visible="True" class="Button-Default-ButtonStyle btn btn-primary" controltype="button" onclick="UserRegistrationApproval_Approve_click(event, event.target, 0, {'RegId':'REG-10000155','FirstName':'Akshay'});" causesvalidation="Yes" style="width: 150px; pointer-events: auto; opacity: unset;">Approve</button>
Request with Apostrophe:
<button type="button" value="Approve" validationgroup="" disableonclick="No" iseof="False" isdefault="false" isenabled="True" title="" visible="True" class="Button-Default-ButtonStyle btn btn-primary" controltype="button" onclick="UserRegistrationApproval_Approve_click(event, event.target, 0, {'RegId':'REG-10000159','FirstName':'A'k'});" causesvalidation="Yes" style="width: 150px; pointer-events: auto; opacity: unset;">Approve</button>
I am sending [FirstName], [LastName], and [UserId] all of which have apostrophes. The button is not clickable. Comparing the HTML with a regular request we see the following difference:Regular Request:
<button type="button" value="Approve" validationgroup="" disableonclick="No" iseof="False" isdefault="false" isenabled="True" title="" visible="True" class="Button-Default-ButtonStyle btn btn-primary" controltype="button" onclick="UserRegistrationApproval_Approve_click(event, event.target, 0, {'RegId':'REG-10000155','FirstName':'Akshay'});" causesvalidation="Yes" style="width: 150px; pointer-events: auto; opacity: unset;">Approve</button>
Request with Apostrophe:
<button type="button" value="Approve" validationgroup="" disableonclick="No" iseof="False" isdefault="false" isenabled="True" title="" visible="True" class="Button-Default-ButtonStyle btn btn-primary" controltype="button" onclick="UserRegistrationApproval_Approve_click(event, event.target, 0, {'RegId':'REG-10000159','FirstName':'A'k'});" causesvalidation="Yes" style="width: 150px; pointer-events: auto; opacity: unset;">Approve</button>