Click here to Skip to main content
15,896,522 members

Comments by Member 10435696 (Top 63 by date)

Member 10435696 28-Mar-14 4:09am View    
I have a ImageViewer Page With Iframe in it..And Server code like this-
frmShowImage.Attributes["src"] = "ImageViewerDownload.aspx?file=" + ContentData;

Then in ImageViewerDownload.aspx i have this code-

protected void Page_Load(object sender, EventArgs e)
{
try
{
Response.ContentType = "image/png";

var filePath = Server.MapPath("~/CmsImage/" + Request.QueryString["file"]);
System.Drawing.Image orignalImage = System.Drawing.Image.FromFile(filePath);
System.Drawing.Image resizedImage = FixedSize(orignalImage, 640, 480);

Response.WriteFile(Server.MapPath("~/CmsImage/" + resizedImage));
Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception Ex)
{
LoggingBase.ErrorLog(CommonConstants.DISCOM_CODE, Ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name);
// mPopupMessage.ShowPopup("Application not Responding : please try later ", false);
}

}



internal static System.Drawing.Image FixedSize(System.Drawing.Image imgPhoto, int Width, int Height)
{
int sourceWidth = Convert.ToInt32(imgPhoto.Width);
int sourceHeight = Convert.ToInt32(imgPhoto.Height);
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;

float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;

nPercentW = ((float)Width / (float)sourceWidth);
nPercentH = ((float)Height / (float)sourceHeight);
if (nPercentH < nPercentW)
{
nPercent = nPercentH;
destX = System.Convert.ToInt16((Width -
(sourceWidth * nPercent)) / 2);
}
else
{
nPercent = nPercentW;
destY = System.Convert.ToInt16((Height -
(sourceHeight * nPercent)) / 2);
}

int destWidth = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);

Bitmap bmPhoto = new Bitmap(Width, Height,
PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.Clear(Color.Black);
grPhoto.InterpolationMode =
InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
new Rectangle(destX, destY, destWidth, destHeight),
new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
GraphicsUnit.Pixel);


grPhoto.Dispose();
return bmPhoto;
}


Now how to write a file which is not saved anywhere on folder.
Response.WriteFile(Server.MapPath("~/CmsImage/" + resizedImage));--->How to write this resized file in frame.Currently this line is giving error
Member 10435696 26-Mar-14 8:50am View    
but all these ways are using server side code but i want it in client side..As i am using Gridview..Plz help
Member 10435696 28-Feb-14 5:35am View    
Hey sory 4 late reply..

My this code starting working..my alerts are giving the correct data..
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'POST',
"url": 'Employee/GetAllNodes',
"contentType": "application/json; charset=utf-8",
"dataType": 'json',
"data": "{}",
success: function (msg) {
alert(msg[0].EMP_ID);
alert(msg[0].PARENT_EMP_ID);
alert(msg[0].EMP_NAME);
alert((msg));
$('#treeViewDiv').jstree({
"json_data": { "data": msg[0].EMP_NAME},--------->This is printing steve
"plugins": ["themes", "json_data"]
});
}
, timeout: 60000
});
});
Member 10435696 27-Feb-14 5:46am View    
i thnk their is prob in my js..can u give ma a link from where i can have js +jstree jquery download latest version
Member 10435696 27-Feb-14 4:46am View    
sorry but how to find that version i have...sory forr this queston