Object reference not set in image handler

2 posts, 0 answers
  1. Josep Bonet
    Josep Bonet avatar
    9 posts
    Member since:
    Aug 2009

    Posted 16 Apr 2010 Link to this post


    here is my problem: I've got two radbinaryimages and each one is in a wizardstep inside an asp.net wizard. In step one, the first binaryimage is displayed, but when I switch to page 2, the second one is empty and I get an "Object reference not set" in the processrequestinternalmethod of the radbinaryimagehandler.
    If I look inside the cache, I can see the data from the visible image but not from the second one.

    The sample belows reproduce the problem. Though it's not a wizard, it's the same problem.

    Did I miss something?

    Best regards


    <telerik:RadBinaryImage runat="server" Visible="true" ID="binaryImage1" /> 
    <telerik:RadBinaryImage runat="server" Visible="false" ID="binaryImage2" /> 
    <asp:Button runat="server" ID="btn" OnClick="btn_Click" /> 

     protected void Page_Load(object sender, EventArgs e) 
                if (!Page.IsPostBack) 
                    byte[] img = File.ReadAllBytes(@"d:\mydocuments\My Pictures\IMG_2787.JPG"); 
                    binaryImage1.DataValue = img; 
                    binaryImage2.DataValue = img; 
    protected void btn_Click(object sender, EventArgs e) 
                binaryImage1.Visible = !binaryImage1.Visible; 
                binaryImage2.Visible = !binaryImage2.Visible; 

  2. Rosen
    Rosen avatar
    3214 posts

    Posted 19 Apr 2010 Link to this post

    Hello Josep,

    The behavior you are experiencing is by design. It is caused by a performance optimization in which the binary data is stored in the cache as late as possible as in this case in control's render/prerender methods. However as you may know when visible is set to false, render/prerender methods will not be called, thus the logic to store the data in the cache is not executed. In order to workaround this you may consider setting initial visible value after prerender for example inside PreRenderComplete event.

    protected override void OnPreRenderComplete(EventArgs e)
        if (!IsPostBack)
            binaryImage2.Visible = false;

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft R3 2016 release webinar banner
Back to Top