Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1117
  • Last Modified:

Update Repeater with AsyncAutopostback (Updatepanel) doesn´t work (VB.NET)

Hi,

I have a problem with the partial reload of a webpage:
 
My webpage has a search function. After hitting the "search" key, the site should only reload the results, not the whole page.

Hitting the "search button", the code passes a SQL-request to the database. The answer creates a Datatable, written in an Repeater.
The Repeater ist only a small part of the site, and the browser should only reload this part: the result of a new query re-fills the Repeater, without generating a whole new site.

This should work with "UpdatePanel"!?

My problem now is, that the query is indeed made¿¿, but the site does not show the result.
In Firebug I can see that the query is executed and the code that arrives at the client itself has also changed correctly (with updated data).

On my Page in the Browser, the Repeater ist not refilled, nothing happens here!

Do you have me a hint? Thank you.


Here is an extract of the code:
 
sub GetContent_Click()
 SQL-Request
 and databinding
end sub



<asp:UpdatePanel ID="UpdatePanel_Search_wikiTicket" UpdateMode="Conditional" runat="Server">
<Triggers>
     <asp:AsyncPostBackTrigger ControlID="GetContent" EventName="Click" />
 </Triggers>
 <ContentTemplate>
     <asp:Button ID="GetContent" runat="server" Text="Update Repeater" OnClick="GetContent_Click"/>

 <asp:Repeater ID="repMaster_wikiTickets" OnItemDataBound="ItemDataBound_wikiTickets" visible="true" runat="server">

my Repeater

</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

Open in new window

0
jbeg
Asked:
jbeg
  • 5
  • 3
1 Solution
 
cb1393Commented:
What happens when you change your updatepanel to the following (without the conditional triggers)?
<asp:UpdatePanel ID="UpdatePanel_Search_wikiTicket" runat="Server">
 <ContentTemplate>

Open in new window

0
 
jbegAuthor Commented:
I've tried this, but, unfortunately, the "same thing".

Thanks for your answer!
0
 
abhinaypCommented:
Remove the trigger n conditional n try.

If that doesnt help remove the updatepanels n chk if the repeater is gettin bind with postback
<asp:UpdatePanel ID="UpdatePanel_Search_wikiTicket" runat="Server">

 <ContentTemplate>
     <asp:Button ID="GetContent" runat="server" Text="Update Repeater" OnClick="GetContent_Click"/>

 <asp:Repeater ID="repMaster_wikiTickets" OnItemDataBound="ItemDataBound_wikiTickets" visible="true" runat="server">
my Repeater
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jbegAuthor Commented:
Thank you for your answer!

Now I have removed the UpdateMode="Conditional". Nothing has changed.

Then I have removed the Updatepanel and when I click the Button, I get a postback and the repeater is gettin bind correctly with the new Content.

When the UpdatePanel is used, there is no postback, nothing happens on my page, but in Firebug I can see, that the repeater is filled with the new content. The databinding is done, but there is no refresh on my page.


0
 
abhinaypCommented:
did u remove the triggers too?
0
 
abhinaypCommented:
Okay, i tried doing the same with the repeater n it did work.

Here is wat i did(I am copy pasting exactly wat i did)
/*********** Aspx**********/

<asp:UpdatePanel ID="UpdatePanel_Search_wikiTicket" runat="Server">
        <ContentTemplate>
            <asp:Button ID="GetContent" runat="server" Text="Update Repeater" />
            <asp:Repeater ID="repMaster_wikiTickets" Visible="true" runat="server">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%#Eval("SampleID")%>' ID="lblID"></asp:Label>
                    <asp:TextBox runat="server" Text='<%#Eval("SampleName")%>' ID="txtName"></asp:TextBox>
                    <br />
                </ItemTemplate>
            </asp:Repeater>
        </ContentTemplate>
    </asp:UpdatePanel>

/**************** Code behind ***********
  Protected Sub GetContent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GetContent.Click
        Dim d As DataTable = SampleData()

        repMaster_wikiTickets.DataSource = d
        repMaster_wikiTickets.DataBind()

    End Sub
    Private Function SampleData() As DataTable
        Dim dt As New DataTable
        dt.Columns.Add("SampleID")
        dt.Columns.Add("SampleName")


        For i As Integer = 1 To 10

            Dim dr As DataRow = dt.NewRow
            dr("SampleID") = i
            dr("SampleName") = "My Name " & i
            dt.Rows.Add(dr)
        Next
        Return dt
    End Function

Open in new window

0
 
jbegAuthor Commented:
Yes, I have removed the triggers.

It´s still the same, I can see in Firebug, that the Repeater ist filled with the new content. This needs 4 seconds (rather slow internet connection).
But there is no refresh on the page.
The new content is shown in firebug, but the page is not updated.
0
 
jbegAuthor Commented:
I've postet the comment above before reading your second comment. I will test this, thank you.
0
 
jbegAuthor Commented:
The example worked and helped me, to find a solution for the problem:
problem was the Response.Write in the code behind. Without it was working.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now