When attempting to execute a postback in ASP.NET MVC after confirming with JavaScript, the following button is used:
<input type="submit" id ="RemoveStatus" value="Remove Status" name="button" onclick="return CheckRemove();"/>
The JavaScript code for the CheckRemove() function is as follows:
var button1 = document.getElementById("RemoveStatus");
if (confirm("Are you sure you want to remove status?") == true)
{
button1.disabled = true;
button1.value = "Removing status...";
__doPostBack('RemoveStatus', '');
return true;
}
else
{
return false;
}
Despite setting the id and populating the button1 in debug, an "object expected" error is encountered at the __doPostBack function. I have attempted passing button1.id and button1 as arguments to __doPostBack, but the postback does not occur and the error persists. Any insights on resolving this issue would be greatly appreciated.