How to save signature to database using ASP.NET Core (Razor Pages)

1 Answer 416 Views
Signature
Janko
Top achievements
Rank 1
Iron
Iron
Janko asked on 12 Sep 2023, 12:12 PM

I've seen Signature component and it's documentation but I haven't seen how to save the signature in DB.

Since there's no SignatureFor component to bind a model attribute to it, how to save a signature as a model attribute?

1 Answer, 1 is accepted

Sort by
1
Accepted
Mihaela
Telerik team
answered on 15 Sep 2023, 10:25 AM

Hi Janko,

You could integrate the Signature editor into the Telerik UI for ASP.NET Core Form, as described in the Form integration section in the documentation.

If you would like to integrate the Signature into a standard HTML form, you could use the HtmlAttributes() method to set the "data-bind" attribute to bind the editor to the respective Model property:

//Model
    public class UserViewModel
    {
        public string UserSignature { get; set; } 
    }

//View
@model UserViewModel

<form id="testForm" method="POST">
    <div>
        @(Html.Kendo().Signature()
                .Name("UserSignature")
                .HtmlAttributes(new { data_bind = "value: UserSignature" })
                .Color("crimson")
                .Width(600)
                .Height(340)
        )
    </div>
    <input type="submit" value="Submit"/>
</form>


Regards,
Mihaela
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Janko
Top achievements
Rank 1
Iron
Iron
commented on 04 Oct 2023, 10:46 AM

Thank you for your answer Mihaela :)

Just to point out for future visitors that it is important that UserSignature is of type string, so you need to have two properties, one of type string for Kendo Signature component and byte[] for handling BLOBs from database.

Tags
Signature
Asked by
Janko
Top achievements
Rank 1
Iron
Iron
Answers by
Mihaela
Telerik team
Share this question
or