I have converted binary data of the image to the text form. But, I need to convert the text data to an image, can I have a solution for that using angularjs in asp.net
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="imagev2.aspx.cs" Inherits="imagev2" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body ng-app="myapp">
<div ng-controller="MyController">
<button ng-click="myData.doClick(item, $event)">Send AJAX Request</button>
<br />
Data from server: {{myData.fromServer}}
</div>
<script>
angular.module("myapp", [])
.controller("MyController", function ($scope, $http) {
$scope.myData = {};
$scope.myData.doClick = function (item, event) {
$http.post('imagev2.aspx/GetEmployees', { data: {} })
.success(function (data, status, headers, config) {
$scope.myData.fromServer = data.d;
})
.error(function (data, status, headers, config) {
$scope.status = status;
});
}
}).config(function ($httpProvider) {
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.post["Content-Type"] = "application/json; charset=utf-8";
});
</script>
</body>
</html>
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
public partial class imagev2 : System.Web.UI.Page
{
[WebMethod]
public static string GetEmployees()
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(@"Data Source=STAGINGSERVER;Initial Catalog=INVOICE;Persist Security Info=True;User ID=sa;Password=tEknomec@1993");
DataSet ds = new DataSet();
try
{
conn.Open();
ds = new DataSet();
cmd = new SqlCommand("GETDATA", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
conn.Close();
conn.Dispose();
}
return JsonConvert.SerializeObject(ds);
}
}