Results 1 to 7 of 7

Thread: Iframe inside updatepanel inside datalist refreshes incorrectly

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Iframe inside updatepanel inside datalist refreshes incorrectly

    Hi
    I have a Datalist with a Button and an Iframe inside the Itemtemplate.
    When I click the button, only the selected item should be refreshed, so I wrapped it with an Updatepanel.

    But whenever I click the button, ALL the iframes in the datalist refreshes, not just the one.

    Code:
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
                <ItemTemplate>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:Button ID="Button1" runat="server" Text="Button" />
                             <iframe id='iframe_id'  src='http://www.pons.za.net'></iframe>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </ItemTemplate>
            </asp:DataList>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                SelectCommand="SELECT top 3 [q_id] FROM [qoutes]"></asp:SqlDataSource>
    I tried putting in async triggers but that did not work either.

    Anyone have an idea what I can do?

    Regards
    appelmeester

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    If you are using an iFrame, why do you need to post back to the server at all?

    You can alter the src or location property of the iFrame using JavaScript, and then the iFrame will update to the new page, without the need for the hosting page to do anything.

    Gary

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    Hi Gary

    Thanks for your response.
    I maybe should have included this to make things more clear.

    I do NOT want to change the Iframe src/location.
    I want to change the button's text value in the datalist whenever the button gets clicked. (this is done in the code behind. I am excluding this for example purposes, it doesnt matter if its there or not)

    None of the Iframes source should be changed/refreshed at all if possible, just the 1 button should be refreshed.

    Whenever I click one of the buttons, ONLY that button's value is changed and ONLY that button gets refreshed via updatepanel, which is correct.

    But for some reason ALL the iframes on the form is reloaded. (I would have been happy if just one is refreshed, but none is even better).

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    Ah, I see what you are after.

    If you do not want the iFrame to be included in the updated content, then you will need to move it out of the UpdatePanel. That would explain why one of the iFrames is being updated, but I am not sure about the others.

    Is it possible to see the markup for the rest of the page?

    Gary

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    ok you answered my question... thanks gary. I was being very silly.
    solution : Do not put the iframe in the updatepanel

    Code:
    <ItemTemplate>
                    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <ContentTemplate>
                            <asp:Button ID="Button1" runat="server" Text="Button" />
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <iframe id='iframe_id' runat="server" src='http://www.google.co.za'></iframe>
                </ItemTemplate>

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2009
    Posts
    16

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    but yes it is still a bit weird why the rest of the iframes also updated, not just the one.
    but thanks a lot Gary for your help!

  7. #7
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Iframe inside updatepanel inside datalist refreshes incorrectly

    Not a problem at all, happy to help!!

    It is still a little strange though, I have to agree. Although, I have never used an iFrame on a page that has an UpdatePanel, so I am not sure what the expected behaviour is.

    Gary

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width