Click here to Skip to main content
12,622,032 members (36,218 online)
   

ASP.NET

 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 23:03
memberAli Al Omairi(Abu AlHassan)27-Feb-13 23:03 
GeneralRe: TextArea value in C# Pin
Sandeep Mewara28-Feb-13 0:16
mvpSandeep Mewara28-Feb-13 0:16 
AnswerRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 21:06
memberAli Al Omairi(Abu AlHassan)27-Feb-13 21:06 
GeneralRe: TextArea value in C# Pin
vanikanc28-Feb-13 3:38
membervanikanc28-Feb-13 3:38 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)4-Mar-13 5:13
memberAli Al Omairi(Abu AlHassan)4-Mar-13 5:13 
QuestionDataset Issue Pin
Abhismart5527-Feb-13 4:18
memberAbhismart5527-Feb-13 4:18 
AnswerRe: Dataset Issue Pin
Abhismart5527-Feb-13 8:15
memberAbhismart5527-Feb-13 8:15 
QuestionProblems with display image byte() on image tag Pin
keidash27-Feb-13 1:36
memberkeidash27-Feb-13 1:36 
Hello All,

I'm try to show images from database in a client side, but, I have been using many kinds of examples that I found and none work, none of the images shown. The last example I saw it's this:
Auto-bind byte[] to asp:Image[^]

I understand perfectly the example, but the images are still not displayed.

Someone help me a bit with this issue?

In summary, I'm use a HTML5 drag & drop files. Send the files via XMLHttpRequest in a FormData object. One handler take this files in byte() and store in SQL DataBase.

Client code:
$("#btnUploadFile").click(function () {
	    if (files.length <= 0) {
	        alert("Debe seleccionar algún fichero para subirlo.");
	    } else {
	        var expID = $("#ContentPlaceHolder1_hfExpId").val();
	        var formData = new FormData();
	        for (var i = 0; i < files.length; i++) {
	            alert(files[i].name);
	            formData.append('file', files[i]);
	        }
	        var xhr = new XMLHttpRequest();
	        xhr.open('POST', "FileHandler.ashx", true);
	        xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
	        xhr.setRequestHeader("ExpedienteID", expID);
	        xhr.onload = function () {
	            if (xhr.status === 200) {
	                RefreshFilePanel();
	            } else {
	                console.log('Something went terribly wrong...');
	            }
	        };
	        xhr.send(formData);
	    };

Handle code:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
        Dim documentBytes As Byte()
        Dim lExpId As String = context.Request.Headers("ExpedienteID")
        Dim fLenght As Integer
        
        If (context.Request.Files.Count > 0) Then
            Dim files As HttpFileCollection = context.Request.Files
 
            For i = 0 To files.Count - 1
                fLenght = files(i).ContentLength
                documentBytes = New Byte(fLenght - 1) {}
                context.Request.InputStream.Read(documentBytes, 0, fLenght)
'This save byte() image on SQL Database:
                UploadDocumentBy_ExpID(documentBytes, files(i).FileName, "Description" & lExpId.ToString, lExpId)
            Next
        End If
    End Sub


More late, I try to put this byte() in a image tag on grid.

aspx code:
<asp:GridView ID="grdDocumentoByExp" runat="server" AutoGenerateColumns="false" Width="250px"
 DataSourceID="dtsDocumentByExpId">
 <Columns>
  <asp:BoundField DataField="Archivo" HeaderText="Archivo" />
  <asp:BoundField DataField="docId" HeaderText="docId" />
  <asp:BoundField DataField="Documento" HeaderText="Documento" Visible="false" />
    <asp:TemplateField HeaderText="Preview">
       <ItemTemplate>
         <asp:Image 
         ID="imgThumb" 
         runat="server"
         ImageUrl='<%# GetImage(Eval("Documento")) %>'
        />
       </ItemTemplate>
    </asp:TemplateField>                                                                
 </Columns>
</asp:GridView>

And the function GetImage in codebehind:
Public Function GetImage(image As Object) As String
    Return "data:image/gif;base64," & Convert.ToBase64String(DirectCast(image, [Byte]()))
End Function

In all steps, there is no error, but I think that the error is posible located in the byte() file format..but i'm not sure.

Someone help me?

Sorry for my inglish and Thanks.
AnswerRe: Problems with display image byte() on image tag Pin
Ali Al Omairi(Abu AlHassan)4-Mar-13 4:26
memberAli Al Omairi(Abu AlHassan)4-Mar-13 4:26 
Questionwhy team is not replyin gmy question Pin
prince_rumeel27-Feb-13 0:13
memberprince_rumeel27-Feb-13 0:13 
AnswerRe: why team is not replyin gmy question Pin
Richard MacCutchan27-Feb-13 2:09
mvpRichard MacCutchan27-Feb-13 2:09 
GeneralRe: why team is not replyin gmy question Pin
prince_rumeel27-Feb-13 21:07
memberprince_rumeel27-Feb-13 21:07 
QuestionSign in with ASP.NET Pin
omarbench26-Feb-13 1:45
memberomarbench26-Feb-13 1:45 
AnswerRe: Sign in with ASP.NET Pin
Sandeep Mewara26-Feb-13 3:16
mvpSandeep Mewara26-Feb-13 3:16 
AnswerRe: Sign in with ASP.NET Pin
ryanb3126-Feb-13 11:34
memberryanb3126-Feb-13 11:34 
AnswerRe: Sign in with ASP.NET Pin
jain jinesh26-Feb-13 20:12
memberjain jinesh26-Feb-13 20:12 
GeneralRe: Sign in with ASP.NET Pin
omarbench26-Feb-13 21:47
memberomarbench26-Feb-13 21:47 
Questionunable to change Web.SiteMap Pin
jojoba201126-Feb-13 0:58
memberjojoba201126-Feb-13 0:58 
AnswerRe: unable to change Web.SiteMap Pin
Sandeep Mewara26-Feb-13 3:24
mvpSandeep Mewara26-Feb-13 3:24 
GeneralRe: unable to change Web.SiteMap Pin
jojoba201126-Feb-13 5:12
memberjojoba201126-Feb-13 5:12 
QuestionBinding gridview from two tables Pin
demoninside925-Feb-13 23:45
memberdemoninside925-Feb-13 23:45 
AnswerRe: Binding gridview from two tables Pin
David Mujica26-Feb-13 6:09
memberDavid Mujica26-Feb-13 6:09 
Questioncustom MVC authorization and Authorize Pin
Super Lloyd25-Feb-13 21:07
memberSuper Lloyd25-Feb-13 21:07 
QuestionMVC Model + Entity Design Guidance Needed. Pin
nlarson1125-Feb-13 12:51
membernlarson1125-Feb-13 12:51 
QuestionDevelop a Custom Login page Pin
Meherab Bhamgara25-Feb-13 4:24
memberMeherab Bhamgara25-Feb-13 4:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 3 Dec 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid