Click here to Skip to main content
15,908,437 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:02
Member 870181328-Feb-13 6:02 
GeneralRe: Create a basic captcha in C#.net Pin
Sandeep Mewara28-Feb-13 6:23
mveSandeep Mewara28-Feb-13 6:23 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:28
Member 870181328-Feb-13 6:28 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:24
Member 870181328-Feb-13 6:24 
GeneralRe: Create a basic captcha in C#.net Pin
Member 870181328-Feb-13 6:29
Member 870181328-Feb-13 6:29 
AnswerRe: Create a basic captcha in C#.net Pin
AshishChaudha28-Feb-13 17:11
AshishChaudha28-Feb-13 17:11 
Questionthreaded function to send email, file io crashes Pin
jkirkerx27-Feb-13 8:29
professionaljkirkerx27-Feb-13 8:29 
SuggestionRe: threaded function to send email, file io crashes Pin
Richard Deeming27-Feb-13 9:30
mveRichard Deeming27-Feb-13 9:30 
GeneralRe: threaded function to send email, file io crashes Pin
jkirkerx27-Feb-13 11:28
professionaljkirkerx27-Feb-13 11:28 
AnswerRe: file io crashes Pin
David Mujica27-Feb-13 10:40
David Mujica27-Feb-13 10:40 
QuestionTextArea value in C# Pin
vanikanc27-Feb-13 8:03
vanikanc27-Feb-13 8:03 
AnswerRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 18:12
mveSandeep Mewara27-Feb-13 18:12 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 20:09
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 20:09 
GeneralRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 21:02
mveSandeep Mewara27-Feb-13 21:02 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 22:03
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 22:03 
GeneralRe: TextArea value in C# Pin
Sandeep Mewara27-Feb-13 23:16
mveSandeep Mewara27-Feb-13 23:16 
AnswerRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)27-Feb-13 20:06
professionalAli Al Omairi(Abu AlHassan)27-Feb-13 20:06 
GeneralRe: TextArea value in C# Pin
vanikanc28-Feb-13 2:38
vanikanc28-Feb-13 2:38 
GeneralRe: TextArea value in C# Pin
Ali Al Omairi(Abu AlHassan)4-Mar-13 4:13
professionalAli Al Omairi(Abu AlHassan)4-Mar-13 4:13 
QuestionDataset Issue Pin
Abhismart5527-Feb-13 3:18
Abhismart5527-Feb-13 3:18 
AnswerRe: Dataset Issue Pin
Abhismart5527-Feb-13 7:15
Abhismart5527-Feb-13 7:15 
QuestionProblems with display image byte() on image tag Pin
keidash27-Feb-13 0:36
keidash27-Feb-13 0: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:
JavaScript
$("#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:
VB
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:
XML
<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:
VB
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 3:26
professionalAli Al Omairi(Abu AlHassan)4-Mar-13 3:26 
Questionwhy team is not replyin gmy question Pin
prince_rumeel26-Feb-13 23:13
prince_rumeel26-Feb-13 23:13 
AnswerRe: why team is not replyin gmy question Pin
Richard MacCutchan27-Feb-13 1:09
mveRichard MacCutchan27-Feb-13 1:09 

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.