.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

display default image when user not uplaoding iamge ...

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :ASP.Net

iam  new to asp.net ...i have stuck here ..and i need help in this..code or anything would help...

i want to show default image in gridview when user is not uploading the image...!! i knw the concept but how to implemnt using code in vb.net. i know to store th eimag ein binary format and retrieve it but how to check it for null and display the deafault image if user not uploading the image. ...please help me out in this..

my code is here: how to insert  null value to image and display default image?

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arrcontent As Byte()
        Dim LEN As Integer
        Dim FN As String = String.Empty
        Dim EXT As String = String.Empty

        If Fu1.HasFile Then

            FN = Fu1.PostedFile.FileName
            Dim ityp = Fu1.PostedFile.ContentType
            Len = Convert.ToInt32(Fu1.PostedFile.InputStream.Length)
            EXT = FN.Substring(FN.LastIndexOf("."))
            EXT = EXT.ToLower()
            If EXT = ".jpg" Or EXT = ".bmp" Or EXT = ".gif" Or EXT = ".png" Or EXT = ".jpeg" Then
                ReDim arrcontent(Len)
                Fu1.PostedFile.InputStream.Read(arrcontent, 0, Len)
                If INSTAB(TB1.Tex

View Complete Post

More Related Resource Links

"Display Image in image Conrtrol when user select Image from Selection_Dialogbox.


Hi all,


         I want to achive on functionallity like below.

         I want to Dispaly image after image selection.so Users  can see image at that moment.

         So Please anybody help me???








deafault iamge dispaly when user not uploading the image


hi this is my code ...iam storing & retrieving image from db using gridview but now i got stuc..how to dispaly default imag ewhen user is not uploading the iamge...

here is my code...plaese help me ...

this is insert image to db......

  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim arrcontent As Byte()
        Dim LEN As Integer
        Dim FN As String = String.Empty
        Dim EXT As String = String.Empty

        If Fu1.HasFile Then

            FN = Fu1.PostedFile.FileName
            Dim ityp = Fu1.PostedFile.ContentType
            Len = Convert.ToInt32(Fu1.PostedFile.InputStream.Length)
            EXT = FN.Substring(FN.LastIndexOf("."))
            EXT = EXT.ToLower()
            If EXT = ".jpg" Or EXT = ".bmp" Or EXT = ".gif" Or EXT = ".png" Or EXT = ".jpeg" Then
                ReDim arrcontent(Len)
                Fu1.PostedFile.InputStream.Read(arrcontent, 0, Len)
                If INSTAB(TB1.Text.Trim, arrcontent, Len, ityp) = True Then
                    L3.Text = "DATA ADDED SUCCECFULLY"
                    L3.Text = "ERROR IN INSERTING DATA"
                End If
                L1.Text = "Only gif,b

Can't display an image from the database



My database has a products table that has images stored in a varbinary(MAX) column.

I'm trying to display product information in a repeater and trying to display the images as well by using a GenericHandler class but I can't get the image to show up in my page.

Here is my Handler.ashx class:

Public Class Handler
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        '== Set up the response settings
        context.Response.ContentType = "image/gif"
        context.Response.BufferOutput = False

        Dim id As Integer = -1
        Dim stream As Stream = Nothing
        If Not String.IsNullOrEmpty(context.Request.QueryString("id")) Then
            id = context.Request.QueryString("id")
            stream = GetImage(id)
        End If

        Const buffersize As Integer = 1024 * 16
        Dim buffer(buffersize) As Byte
        'byte[] buffer = new byte[buffersize];
        Dim count As Integer = stream.Read(buffer, 0, buffersize)

        While count > 0
            context.Response.OutputStream.Write(buffer, 0, count)
            count = stream.Read(buffer, 0, buffersize)
        End While


Error on Display user's fullname using Active Directory in asp.net using vb.net



wi As System.Security.Principal.WindowsIdentity =  _System.Security.Principal.WindowsIdentity.GetCurrent()



Dim a As String() = HttpContext.Current.User.

Session problem with display of image in row of reportviewer


Hello techies...

I am new to this sql reporting service. But anyhow by surfing I am able to bind the report but i was stuck in image display.

Anyways, i also managed that. But the real problem is whenever i was keeping a image control in rdlc report i was having session prob. If i remove the image control then as usual report works fine.

Please suggest me some solution.... either for session problem or for image display. I am keeping the image name in database but for binding the rdlc report i am using a store procedure which return the path (static) concating with the image name(kept in database).

Hope to find a solution .....

Cannot Display Image in Report


 I have a report using an image control that needs to display an image inside subfolder "Images\InstitutionLogos\".

On properties of image control i have the following properties set:

MIMEType= "image/png"

Source      = Database

Value        ="\Images\InstitutionLogos\" +Fields!InstitutionID.Value+".png"

Inside subfolder "Images\InstitutionLogos\" each image is named with a number which represents Fields!InstitutionID.,(ex, 1.png, 2.png, 10.png)

However, when i run the report the image just displays an X, what am i missing?

Passing Primary Key to User Control to Display Record Detail


I'm building a user control to display detail information on a parent record. The user control will be displayed via an Ajax Modal Popup. The user control works and is displayed when expected. The problem that I'm having is that I'm not able to pass in the primary key for the parent. The control is displayed via the _ItemCommand event of a Repeater. In the markup for the user control, I explicity set the ContactId to 0 to avoid an error when the control loads (its still underdevelopment, eventually that I'll check if the value is valid).

I was assuming that I could change the property in the _ItemCommand event, but obviously its not working.

In the Page_Load event this code successfully sets the ContactId property of the control. The _ItemCommand event appears to set the value. However when I set a test label on the user control to the Me.ContactId, its showing '0' as if it was never passed in.

        UserControlContactDetail.ContactId = "1462"
        test.Text = UserControlContactDetail.ContactId

    Protected Sub RepeaterDirectory_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterDirectory.ItemCommand

Protected Sub RepeaterDirectory_ItemCommand(By

How To display image in GridView as hyperlink


Hello Everyone 

Could someone please help me with a little issue....

I was able to save the image in the database as binary....... but now i don´t know how to display it in the GridView as a hyperlink.

I´ve read something about ImageField..... I´d appreciate any help .


How can I allow user to manipulate an image behind another image?



I am working on an administration web page for an iPhone application that will allow users to upload their logo.   The page will have an image of the iPhone app with a transparent space where their logo would go.  I would like the users to be able to manipulate their logo by dragging it and resizing it into the space on the iPhone app template.

Does anyone have a good approach for this?

I have tried the AJAX ResizableControlExtender, but I can't get it to work behind the template image.  Once I add a position:absolute attribute, the resize control no longer works.

I can make buttons that adjust the top, left, width, and height properties via javascript, but that isn't as user friendly as being able to drag and resize the image with the mouse.

Does Silverlight have a good solution for this?

Any ideas are welcome.

Thank you!


When the user want click on document library that should be navigate default view



I have document library which is having folders,the document library i have displayed as tree view in the left side of the page.

Here Document library having views,suppose i have selected one view on the document library it is navigating the particular view that is good but when i am trying to click document library folder still the page in same view do not navigate the default view .

I need when ever i click on any of the folder in document library that should navigate defualt view ,could you please help me on this.

Really its need urgent...


Display image icon in HyperLinkField of Gridview

 Hello everyone! Can someone please tell me how to display an image in a HyperLinkField of a gridview?  Instead of words, I just want to show a simple little icon that can be clicked on and pass a query string to the next page.  The first hyperlink field I have set up works perfectly and passes the querystring to the next page.   The second hyperlinkfield is my attempt at showing the image but it's giving me a squiggly and telling me "the element img cannot be nested within the element hyperlinkfield" I got this technique from this brief article   - I would like to accomplish exactly what it says it is suppose to do. Thanks!   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="clientID"> <Columns> <asp:BoundField DataField="clientFirstName" HeaderText="First Name" /> <asp:BoundField DataField="clientLastName" HeaderText="Last Name" /> <asp:HyperLinkField HeaderText="More Info" Text="View more info..." DataNavigateUrlFields="clientID" DataNavigateUrlFormatString="Cli

Display XAML workflow image in browser and hightlight the current Activity

I have a requirement in project to display the XAML workflow in browser as image like the Visual studio designer displaying and it should Hightlight the current activity in workflow.  Please guide me on this.rajeevkalyan

User display Name & People Picker

Hi, We wanted to use a web application without user profile service. We have added users their display name is always domain\username. Is it that without user profile service display names will not be updated. But my understanding is that people picker also returns display name. Is it something else we need to configure to get the displayname from the people picker itself.Satheesh

Is it possible to display the friendly name or email address of LiveID User Using Claims Authenticat

We have finally gotten LiveID authentication to work.  However when we specify a user to add to a sharepoint group, we need to do it via the unique id that live uses.   The user does login using their usual email address and password, but on the sharepoint side they see the PUID@live.com as the logged in user, and when we want to specify the user to have access to the a particular site or library, we have to do it by the same PUID@live.com.  This display makes it difficult to manager users on the sharepoint side.   Is there something I missed on setting up of the authentication provider, or is there something I can do to get sharepoint to retrieve the other information so that we can view the user through the email or full name that live provides?   Steve Paplanus

display image in gridview - unlucky with tutorials

I'm trying to display images in a gridview, but after following the examples of maybe 7 different tutorials I still haven't succeded. There are always some things that go unexplained. My latest attempt is according to this tutorial:http://www.aspdotnetcodes.com/Insert_Images_Database.aspxProblem No1: what exactly should I write in my ashx-file? Following the example in the tutorial this is the code so far:<%@ WebHandler Language="C#" Class="ImageHandler" %> using System; using System.Web; using System.Configuration; using System.Data.SqlClient; public void ProcessRequest (HttpContext context) { SqlConnection myConnection = new SqlConnection("DBPejganConnectionString1"); myConnection.Open(); string sql = "Select Image_Content, Image_Type from ImageGallery where Img_Id=@ID"; SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.Parameters.Add("@ID", SqlDbType.Int).Value = context.Request.QueryString["id"]; cmd.Prepare(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); context.Response.ContentType = dr["BildTyp"].ToString(); context.Response.BinaryWrite((byte[])dr["BildData"]); dr.Close(); myConnection.Close(); }Please give me a hint (or rather the answer) on what's missing. The rest of the problems comes later... :)

How to create SPUser obj or SPRoleAssignment using the user display name not using login name "domai

Suppose there is a user called "Jake Gittes" with login name "domain\jakeg". Now I want to create either SPUser/SPRoleAssignment object using the user full name ("Jake Gittes"). I tried using SPWeb.AllUsers["Jake Gittes"]. But it is throwing exception.

How to Display Binary Image in RDLC in asp.net?

Hi, I want to display Binary image from Database in RDLC. Can some one help me out.   Thanks in advance..  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend