I want to bind this already existing function to a button. The function is tested and it completely working. It is important to me to keep all of the code in one razor page.
@functions
{
public void LogCheck()
{
string loginemail = Request["loginemail"];
string loginpassword = Request["loginpassword"];
string requestedUrl = "/randomtestpage1/";
IMember memberIfApproved = SC.Code.Controllers.UserController.GetByEmail(loginemail);
if (Membership.ValidateUser(loginemail, loginpassword))
{
FormsAuthentication.SetAuthCookie(loginemail, true);
Response.Redirect(requestedUrl);
}
}
}
<form id="loginForm">
<div class="form-group">
<div class="form-group">
<label class="sr-only form-control-label">Email</label>
<div class="mx-auto col-sm-10">
<input class="form-control" name="loginemail" type="email"/>
</div>
</div>
<div class="form-group">
<label class="sr-only form-control-label">Password</label>
<div class="mx-auto col-sm-10">
<input class="form-control" name="loginpassword" type="password"/>
</div>
</div>
</div>
<div class="form-group">
<div class="mx-auto col-sm-10 pb-1 pt-1">
<button id="loginbtn" type="button" class="btn btn-outline-secondary btn-lg btn-block" >@Umbraco.AssignedContentItem.GetPropertyValue("signInButtonText")</button>
</div>
</div>
</form>
I tried adding onclick="@LogCheck()"
to the button element, but that messes up the syntax.
Compiler Error Message: CS1502: The best overloaded method match for 'System.Tuple.Create(object, int)' has some invalid arguments
I also tried to call it from a jQuery, but again error.
$('#loginbtn').click(function() {
@LogCheck();
});
I tried everything mentioned here.