jeudi 23 juillet 2015

Referencing a checkbox value from HTML to C#

I have a checkbox on my .cshtml page that when it is checked I want it to NOT send and e-mail to the user. Below is the various pages of code that I have to transfer the boolean value from the .cshtml page to the .cs mailer code but somewhere the value is not transferring. Please help.

In View.cshtml I put the checkbox in:

<input class="checkbox_priority" id="no_emails" name="emails" type="checkbox" value="true" title="This only applies to the 'Complete' button"/>Do not send e-mail to requestor.

In Notification.cs I get/set the value:

public virtual Boolean no_emails { get; set; } //Used to not send an e-mail to the creator of a request.

And then finally I put the IF statement into the mailer code on RequestService.cs:

if (!review.Status.IsActive && !no_emails)
            message = "The response to your <a href=\"{0}\">request</a> has been completed";
        Helpers.Notifier.CreateNotification(request.Author, request, string.Format(message, Helpers.Link.RequestLink(request.Id)));

However, it is saying that no_emails does not exist in the current context. How do I get the code to recognize no_emails has a boolean value from the .cshtml page?




Aucun commentaire:

Enregistrer un commentaire