我正在尝试签名板并设置其中一个示例。但我不知道如何将图像保存为 jpeg 或类似的东西。
我正在尝试保存图像,然后将其显示在占位符中,以便我可以看到它有效。
下面是我的代码:
默认.aspx
<head runat="server">
<script src="scripts/jquery.min.js"></script>
<script src="scripts/jquery.signaturepad.min.js"></script>
<script src="scripts/json2.min.js"></script>
<link rel="stylesheet" href="scripts/jquery.signaturepad.css"/>
<script type="text/javascript">
$(document).ready(function () {
$('.sigPad').signaturePad({ drawOnly: true });
});
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server" class="sigPad">
<label for="name">Print your name</label>
<input type="text" name="name" id="name" class="name"/>
<p class="drawItDesc">Draw your signature</p>
<ul class="sigNav">
<li class="drawIt"><a href="#draw-it">Draw It</a></li>
<li class="clearButton"><a href="#clear">Clear</a></li>
</ul>
<div class="sig sigWrapper">
<div class="typed"></div>
<canvas class="pad" width="198" height="55"></canvas>
<input type="hidden" name="output" class="output"/>
</div>
<button type="submit">I accept the terms of this agreement.</button>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</form>
</body>
</html>
默认.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
var sigToImg = new SignatureToImage();
var signatureImage = sigToImg.SigJsonToImage(signatureJson);
// I want to be able to add the image to Placeholder1 after the post back
}
}