When i try to capture image using asp.net button the image not capturing by webcam. and when i capture by html button its capturing image. i want to use asp.net button. what to do in this case...
my code is below...
This is my webmethod to capture image by webcam.
- [WebMethod()]
- public static bool SaveCapturedImage(string data)
- {
-
-
-
-
-
-
-
-
- string fileName = DateTime.Now.ToString("dd-MM-yy_hh-mm");
- byte[] imageBytes = Convert.FromBase64String(data.Split(',')[1]);
-
- string filePath = HttpContext.Current.Server.MapPath(string.Format("~/CapturedImage/{0}.jpg", fileName));
- File.WriteAllBytes(filePath, imageBytes);
- return true;
- }
javascript code to capture image....
- <script type="text/javascript">
- $(function () {
- Webcam.set({
- width: 320,
- height: 240,
- image_format: 'jpeg',
- jpeg_quality: 90
- });
- Webcam.attach('#webcam');
- $("#btnCapture").click(function () {
- Webcam.snap(function (data_uri) {
- $("#imgCapture")[0].src = data_uri;
- $("#btnUpload").removeAttr("disabled");
- });
- });
- $("#btnCapture").click(function () {
- $.ajax({
- type: "POST",
- url: "captureimage.aspx/SaveCapturedImage",
- data: "{data: '" + $("#imgCapture")[0].src + "'}",
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (r) {
- windo.close();
- window.location.href = '/studentpage.aspx';
- }
- });
- });
- });
-
- </script>
This is my button code....
i have commented the as.net button.
- <input type="button" id="btnCapture" value="Capture" class="buttondesign" />
- <%--<asp:Button ID="btnCapture" runat="server" Text="Capture" CssClass="buttondesign" OnClick="btnCapture_Click1" />--%>
-