We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Saving Signature

Hello

I am building an asp.net application that saves the signature from the signature control to an image on the web server. The problem I am facing is I can not figure how. The only info I can find is either saving to sql, saving to the clients computer or saving the signature in a PDF. I need to only save the signature as an image.

8 Replies

DL Deepa Loganathan Syncfusion Team January 28, 2019 12:42 PM UTC

Hi Larry,

 
 
Thanks for contacting Syncfusion support. 
 
 
We understood your requirement to save the Signature as an image in the server.  
 
1.      To save Signature as an image in the server. 
 
We have already published a KB based on your requirement. Please check the below link. 
 
 
 
 
2.      To save Signature as an image in the local machine 
 
You can make use of the Save method of Signature. Please our below help links for your reference.  
 
 
 
 
Regards, 

Deepa L.
 
 



LZ Larry Zwegat January 28, 2019 01:20 PM UTC

Yes, I saw that example but I could not get it to work in my code. Can you provide a demo and if possible in vb. Thanks


DL Deepa Loganathan Syncfusion Team January 29, 2019 01:11 PM UTC

Hi Larry, 
 
Thanks for your update. 
 
Based on your requirement of “saving to the signature as an image in a folder in our application (server)”, we have prepared a sample and attached below in your expected VB platform. 
 
 
Please download and check the sample if it meets your requirement and get back to us if you have any further queries.  
 
We will be happy to assist you. 
 
Regards, 

Deepa L.
 



LZ Larry Zwegat January 29, 2019 03:19 PM UTC

The demo is exactly what I was looking for. Thank You. 

When I put the code in my project and click on the Save image to folder button nothing happens. The demo works just fine. Is there something I am missing.


LZ Larry Zwegat January 29, 2019 03:24 PM UTC

Never Mind I found the issue. The script manager needs page methods enabled. Thank You so much. 


DL Deepa Loganathan Syncfusion Team January 30, 2019 04:41 AM UTC

Hi Larry,  
 
You are most welcome.  
 
Please get back to us if you have any further queries. 
 
Regards,  
Deepa L.  



PA Paul replied to Deepa Loganathan September 29, 2022 02:32 PM UTC

Is there a code behind way of getting at the signature value?

If a signature is on a form with other data, I want to be able to save the form data with said signature in one routine i.e. from a Save button.  Your example implies either having two save routines, or saving the entire dataset using Javascript...The former creates a mess and the latter beckons the question of "what's the point of using ASP.NET?".

The whole point of ASP.NET was to keep all the nasty details of HTTP and Javascript at arms length...that seems to have died along with the concept of designing and testing software. 


SS Sivakumar ShunmugaSundaram Syncfusion Team October 5, 2022 11:00 AM UTC

Hi Paul,


We understand that you want to get the Syncfusion EJ Signature value on the server side while clicking the submit button. We would like to let you know that, currently, we do not have a way to get the Signature value on the server side while clicking the submit button.


To achieve your requirement, we have prepared a simple sample of ASP.NET Web Forms with Syncfusion EJ Signature control and manually triggered the Signature upload page method while clicking on the submit button. We have attached the prepared sample for your reference.


Refer to the below code snippet.

[Default.aspx]

 

<div class="frame ">

<h2>Signature:</h2>

<div class="control">

    <ej:Signature ID="Signature1" Height="400px" StrokeWidth="3" IsResponsive="true" runat="server"></ej:Signature>

</div>

<br />

<br />

...

<asp:Button ID="Button1" runat="server" Text="submit" OnClientClick="btn1Click();" OnClick="Button1_Click" /><br /><br /><br />

...

<asp:Label ID="userInput" runat="server"></asp:Label> <br /><br /><br />

...

<asp:TextBox id="TextArea1" TextMode="multiline" Columns="50" Rows="5" runat="server" />

</div>

 

<script>

function btn1Click() {

           

    var target = $("#<%=Signature1.ClientID%>").ejSignature("instance")._canvas[0].toDataURL()

    PageMethods.Upload(target, onSucess, onError);

 

    function onSucess(response) {

        alert("succesfully sent to datasource")

    }

    function onError(response) {

        alert('Something wrong.');

    }

}


[Default.aspx]

 

public partial class _Default : Page

    {

        static string signatureValue { get; set; }

        ...

        [System.Web.Services.WebMethod]

        public static string Upload(string target)

        {

            signatureValue = target;

            var stream = new MemoryStream();

            var writer = new StreamWriter(stream);

            writer.Write(target);

            writer.Flush();

            stream.Position = 0;

            SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=D:\support\asp_webform\signature\WebSample677502731\WebSample\App_Data\Signaturedata.mdf;Integrated Security=True;Connect Timeout=30");  // set your system local fle location

            con.Open();

            string query = "INSERT INTO newData (DataValue) VALUES ('" + stream + "')";

            SqlCommand cmd = new SqlCommand(query);

            cmd.Connection = con;

            cmd.ExecuteNonQuery();

            con.Close();

 

            return target;

        }

        ...

        protected void Button1_Click(object sender, EventArgs e)

        {

            userInput.Text = UserName.Text;

            TextArea1.Text = signatureValue;

        }

    }

}


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebSample919771080.zip


Please check the shared sample and get back to us if you need any further assistance.


Regards,

Sivakumar S


Loader.
Live Chat Icon For mobile
Up arrow icon