How To Set Memory Stream As The Image Control's Source Property
Dec 10, 2010
I have an asp.net image control in one ASP.NET page and have a Memory Stream which has an image.How can i convert this memory stream to set it as the image source without storing the image in the hard disk ?
I've basically got 2 applications. One is my back office application (Admin) and the other , the front end application (web site)
My problem is that, the admin uploads 'n' number of photos ,which is stored in one of the folders within my back office application and the path is stored in my DB as , for example : ~/Uploads/test.jpg.
But it is not possible for me to access this image from my front end application because the path actually exists in my back office app. How do i get to view the images that I uploaded on my front end Appn. ?
Traditionally with an Object Data Source, the wired up class will have its public properties available for binding (i.e. Gridview columns, etc.) which works well. But what if one of my wired up business objects has a property that is an object itself; can I drill down to a property on that object property and still use it?
So in additiona to the traditional:MyBusniessObject.OrderID...I want to use:MyBusniessObject.Customer.NameID Your 1st response might be to just wire up the 'Customer' class, but I need properties both on 'MyBusinessObject'and 'Customer'. I do not think this can be done, as the ODS will not display properties on an object instance property. I have tried manually typing in the drilled down value as well, but that wasn't a success either.
in previously asked question answeres said they dont get what i want to do exactly so heres is the full code also i simply want that instead of a TABLESe i rendered an image( of the content ) on the page
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.IO; using System.Text; using System.Data; using System.Drawing; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { System.Web.UI.WebControls.Panel panelmain = new System.Web.UI.WebControls.Panel(); System.Web.UI.WebControls.Literal abc = new System.Web.UI.WebControls.Literal(); abc.Text = "as<br/>dasdas<br/>dasdad"; DataSet ds = new DataSet(); DataTable dt; DataRow dr; DataColumn idCoulumn; DataColumn nameCoulumn; dt = new DataTable(); idCoulumn = new DataColumn("ID", Type.GetType("System.Int32")); nameCoulumn = new DataColumn("Name", Type.GetType("System.String")); dt.Columns.Add(idCoulumn); dt.Columns.Add(nameCoulumn); dr = dt.NewRow(); dr["ID"] = 1; dr["Name"] = "Name1"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["ID"] = 2;.............
Is is possible to update an image on an HTML page using the response stream of an ASP.NET Generic Handler? For example, if I have the following code on a handler: [URL]
How can I call the handler in jQuery, using .ajax, and set an image on the page equal to the image that is returned by the Handler? I am ignoring the query string variable at the moment as I just want to get this working. Secondly, if I can do above, how can I loop through all of DIVs on the page that are of class "content", select a guid out of a hidden field to use as my query string parameter, and update the associated image within the same content DIV tag? A content div tag would look as follows:
I would like to have all the images updated on a periodic interval, so essentially, as a quick recap, I would need to have: A loop through all of my DIVs of class "content", occuring every n. seconds. Extractation the GUID from the hidden field. A call to my ASHX handler to get the updated image. Set the returned image to the corrisponding image on the page. Is this something that would be difficult to achieve? If not, what would I need to do to make this function in the above manner?
I have an excel file in my Response Output stream. I can Open the stream as a file after a prompt, but it doesn't seem I can save it directly to a specified folder on my client.
I couldn't decide where would be the most apprioate. I looking for an online source control site, if such a thing exists? I've checked out codeplex and thats really for open source projects ? which this isn't. does anyone have a recommendations?
System.Drawing.Image newImage; using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length)) { ms.Write(imageBytes, 0, imageBytes.Length); newImage = System.Drawing.Image.FromStream(ms, true); }
and now I need to have this image as a source for asp:Image (System.Web.UI.WebControls.Image). Is this possible as I know that conversion is impossible?
Im getting some images from a webpage at a specified url, i want to get their heights and widths. I'm using something like this:
Stream str = null; HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(ImageUrl); HttpWebResponse wRes = (HttpWebResponse)(wReq).GetResponse(); str = wRes.GetResponseStream(); var imageOrig = System.Drawing.Image.FromStream(str); int height = imageOrig.Height; int width = imageOrig.Width;
My main concern with this is that that the image file may actually be very large,Is there anything I can do? ie specify to only get images if they are less than 1mb?or is there a better alternative approach to getting the dimension of an image from a webpage?
So I'm working on a site that is going to need a file upload control where the user would be able to upload an image, and then the page would postback causing the image to appear for their viewing (before they submit the data to the database, the image is being stored as type image). What I do now is have my own private web form where people send me their image, I format it accordingly and use the following simple code to upload it:
byte[] newimage = fileUpImgFile.FileBytes; var myDataTable = (from item in context.TypeSet where item.Number == txtBxNumber.Text.Trim() select item).ToList(); foreach (Type item in myDataTable) { item.Photo = newimage; } context.SaveChanges();
Which works, but in this case, it would only work if the record exists already in the database so the person would have to save the data, then go back in and upload the image (inconvenient and inefficient). Is there a way to upload it, store it in memory, and then display it, without saving it to the database?
I am displaying a table into a gridview for which I've a SQL query written which uses IF-ELSE condition. In one of the conditions, if the condition stands TRUE then one of the coloms should be eliminated from the table. But I constantly get an error:"A field or property with the name 'IXC_Vendor_Circuit_ID' was not found on the selected data source."
I have an insert that uses an object data source with out the direction property set and it works fine. I noticed the direction property though and wondered if I should use it.Should the direction property for the parameters of an object data source be used with a simple CRUD operations?
I'm trying to understand when to use the type property and when to use the dbtype property. I looked online but couldn't find a good article that said when and why.
I have created a gridview at runtime. its working fine when i load the grid first time. after when i am selecting next value from ddl to load grid according to that option(selecting from dropdown list and coresponding values showing in grid) showing error that "A field or property with the name 'datafield name' was not found on the selected data source." might be i am getting this error becuze the privious value is not being cleared" can anybody help me with this problem.
I am using two gridviews with one datasourse. I am getting one error
A field or property with the name 'Empid' was not found on the selected data source. Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: A field or property with the name 'Empid' was not found on the selected data source. Source Error:
My code is
<asp:GridViewid="gridview" runat="server" DataSourceID = "SqlDataSource1" PageSize="30" EmptyDataText = "No Records Found" EmptyDataRowStyle-HorizontalAlign ="Center" AllowPaging="true"
I am building an asp.net application, using II6 on windows server 2003 (vps hosting).
I am confronted with an error I didn't receive on my development machine (windows 7, iis 7.5, 64 bit).
When my wcf service tries launching my query running against a local sql server this is the error I receive:
Memory gates checking failed because the free memory (43732992 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.
I have both VS 2005 and 2008 installed on my machine. 2005 is fine. For 2008, literally any asp.net project I try to create gets this eror. I try stepping into the code, and the error occurs apparently before anything that I can trap is loaded. There is no information written to the event log. I have tried this with a "Hello World" webpage with nothing else going on. Seems unique to my Windows Server 2003 machine.
I am getting a weird error in asp.net while using leadtools imaging api. Here's the stack trace.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at SetThreadData(_THREADDATA* ) at Leadtools.Codecs.CodecsOptions.Use() at Leadtools.Codecs.RasterCodecs.DoSave(SaveParams saveParams) at Leadtools.Codecs.RasterCodecs.Save(RasterImage image, Stream stream, RasterImageFormat format, Int32 bitsPerPixel)........
I am maintaining C# .NET code written by somebody else, I get following exception few times,Attempted to read or write protected memory. This is often an indication that other memory is corruptThe code structure where I get the above exception is somethign like this,- it is using ref variables in following sequence,Variable-1 and variable-2 are local variables in App1, - App1: func1() which passes these variables reference to func2(), - App1: func2() passes same variables reference via .net remoting to another application (App2).-App2: does the same passes same received reference to another call 2 times.- The execption is occured while returning from App2.
(App1:func1(ref Var1, ref Var2) --> App1:func2(ref Var1, ref Var2) <---App1 .net remoting to App2--> App2:func3(ref Var1, ref Var2)--> App2:func4(ref Var1, ref Var2)-->variables getting updated and function returned to original caller)
My doubts are ,1. Is passing reference variables in such chain is correct? will it cause such exeption? Does .net support ref variable call directly?