locked
Updatepanel and tabcontainer RRS feed

  • Question

  • User1294399168 posted

    I'm facing for some months following problem:
    When a list of 40 records is loaded and shown in a datalist (or repeater) (with a vertical scrollbar) I want to change for example the 39th record. In the working example (without tabcontainer) just the 39th record changes and I stay on the same position as before.
    In the tabcontainer this does not work although I use a updatepanel. After i pushed on the linkbutton the repeater is loaded again but the position is now the first record and I have to use the scrollbar again.
    Anyone can help??

    This does not work ....
    <asp:UpdatePanel ID="UpdatePanel1" runat="Server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" OnClientActiveTabChanged="clientActiveTabChanged" BorderStyle="None" TabStripPlacement="TopRight" VerticalStripWidth="100px"
    UseVerticalStripPlacement="True" BorderColor="Silver">
    <asp:TabPanel runat="server" ID="TabPanel1">
    <asp:Repeater ID="rptLeerplan" runat="server" OnItemDataBound="Repeater_ItemDataBound" OnItemCommand="repeater_ItemCommand" >
    <asp:Label ID="LabDoel" runat="server"></asp:Label>
    <asp:LinkButton ID="lnkbtnBewaarDoel" runat="server" CommandArgument='<%#Eval("clid")%>' OnCommand="BewaarDoel_Command" ></asp:LinkButton>
    <asp:Label ID="LabAantalreg" runat="server"></asp:Label>
    </asp:Repeater>
    </asp:TabPanel>
    <asp:TabPanel runat="server" ID="TabPanel2" >
    ...
    </asp:TabPanel>
    </ContentTemplate>
    </asp:UpdatePanel>

    Code behind:
    Protected Sub BewaarDoel_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
    ... bind repeater ...
    UpdatePanel1.Update()
    End sub


    This works without tabcontainer
    <asp:UpdatePanel ID="UpdatePanel1" runat="Server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:Datalist ID="lstDoelen" runat="server" OnItemDataBound="lstDoelen_ItemDataBound" DataKeyField ="clid">
    <asp:Label ID="labDoel" runat="server" ></asp:Label>
    <asp:LinkButton ID="lnkbtnBewaarDoel" runat="server" CommandArgument='<%#Eval("clid")%>' OnCommand="BewaarDoel_Command"></asp:LinkButton>
    <asp:Label ID="LabAantalreg" runat="server"></asp:Label>
    </asp:Datalist>
    </ContentTemplate>
    </asp:UpdatePanel>

    Code behind:
    Protected Sub BewaarDoel_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
    ... bind datalist .....
    UpdatePanel1.Update()
    End sub

    Wednesday, February 5, 2020 8:39 AM

Answers

  • User1294399168 posted

    Hi Sam,

    Thxs for the effort but that is not what I want. I need the outside updatepanel also for executing the application faster.
    Anyway I appreciate the help you offered me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 17, 2020 3:27 PM

All replies

  • User288213138 posted

    Hi resource18,

    <asp:UpdatePanel ID="UpdatePanel1" runat="Server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" OnClientActiveTabChanged="clientActiveTabChanged" BorderStyle="None" TabStripPlacement="TopRight" VerticalStripWidth="100px"
    UseVerticalStripPlacement="True" BorderColor="Silver">
    <asp:TabPanel runat="server" ID="TabPanel1">
    <asp:Repeater ID="rptLeerplan" runat="server" OnItemDataBound="Repeater_ItemDataBound" OnItemCommand="repeater_ItemCommand" >
    <asp:Label ID="LabDoel" runat="server"></asp:Label>
    <asp:LinkButton ID="lnkbtnBewaarDoel" runat="server" CommandArgument='<%#Eval("clid")%>' OnCommand="BewaarDoel_Command" ></asp:LinkButton>
    <asp:Label ID="LabAantalreg" runat="server"></asp:Label>
    </asp:Repeater>
    </asp:TabPanel>
    <asp:TabPanel runat="server" ID="TabPanel2" >
    ...
    </asp:TabPanel>
    </ContentTemplate>
    </asp:UpdatePanel>

    Code behind:
    Protected Sub BewaarDoel_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
    ... bind repeater ...
    UpdatePanel1.Update()
    End sub

    Based on your description, I can't reproduce your question.

    Can you show me your code behind?

    Best regards,

    Sam

    Thursday, February 6, 2020 7:28 AM
  • User1294399168 posted

    Sure, I'm glad that there is someone who tries to solve the problem ...

    this happens when the linkbutton is hit:
    Protected Sub BewaarDoel_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
    Dim clid As String = e.CommandArgument
    Dim tbNaam As String = Session("tabel")
    Dim datum As Date = txtDatum2.Text
    lestijd1 = dropLestijden.SelectedValue.ToString
    If lestijd1 <> "" Then
    lestijd = Convert.ToInt32(lestijd1)
    Else
    Exit Sub
    End If

    Dim zoekstring As String = ""
    Dim cn As New SqlConnection(Session("verbinding"))
    cn.Open()
    Try
    zoekstring = "IF NOT EXISTS(SELECT agClid from " & tbNaam & " WHERE agClid = '" & clid & "' AND agLkrid = '" & Session("lkrid") & "' and agSchoolid = '" & Session("schoolid") & "' AND lestijd = '" & lestijd & "' AND agDatum = '" & datum.ToString("yyyy/MM/dd") & "' and agAnker = '" & Session("ankernummer") & "') INSERT INTO " & tbNaam & " (agClid) VALUES (@clid)"
    Dim cm As New SqlCommand(zoekstring, cn)
    cm = New SqlCommand(zoekstring, cn)
    cm.Parameters.AddWithValue("@clid", clid)
    cm.ExecuteNonQuery()
    zoekstring = Session("zoekstring")
    If zoekstring <> "" Then
    'openen datareader
    cm = New SqlCommand(zoekstring, cn)
    Dim reader As SqlDataReader = cm.ExecuteReader()
    'bepalen(waarden)
    If reader.HasRows Then
    rptLeerplan.DataSource = reader
    rptLeerplan.DataBind()
    reader.Close()
    Else
    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Geen resultaten bij je zoekactie.');", True)
    End If
    End If
    Catch
    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Er is een technisch probleem. Foutcode: AGD003.');", True)
    Finally
    cn.Close()
    End Try
    UpdatePanel1.Update()

    End Sub

    And the binding of the repeater:
    Sub Repeater_ItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
    Dim tbNaam As String = Session("tabel")
    Dim labClid As Label = e.Item.FindControl("labClid")
    'arrow
    Dim lnkbtnBewaarDoel As LinkButton = e.Item.FindControl("lnkbtnBewaarDoel")
    LabAantalreg.Text = ""
    Dim dataClid = e.Item.DataItem("clid").ToString
    Dim dataDoel = e.Item.DataItem("cldoel").ToString
    Dim agCount As Integer = 0
    Dim agId As Integer = 0
    Dim zoekString1 As String = ""
    'number
    zoekString1 = "select count(*) as aant from " & tbNaam & " WHERE agClid = '" & dataClid & "' and agSchoolid='" & Session("schoolnummer") & "' AND (agLkrid='" & Session("lkrid") & "' OR (shareLkrid = '" & Session("lkrid") & "' or shareLkrid2 = '" & Session("lkrid") & "' OR shareLkrid3 = '" & Session("lkrid") & "') ) and agDatum >= '" & datum1.ToString("yyyy/MM/dd") & "' and agDatum <= '" & datum2.ToString("yyyy/MM/dd") & "'"
    'DEMOCODE
    Dim cn As New SqlConnection(Session("verbinding"))
    Dim comm As New SqlCommand(zoekString1, cn)
    Dim oSqlAdapter As New SqlDataAdapter(comm)
    Dim oDataSet As New DataSet
    Try
    cn.Open()
    oSqlAdapter.Fill(oDataSet, "resultTable")
    If Integer.Parse(oDataSet.Tables("resultTable").Rows(0).Item("aant")) > 0 Then
    agCount = Integer.Parse(oDataSet.Tables("resultTable").Rows(0).Item("aant"))
    End If
    Catch ex As Exception
    Throw ex
    Finally
    'number text
    LabAantalreg.Text = "<td class='style21' width='1px'>" & agCount & "</td>"
    labDoel.Text = "<td class='style8'>" & HighlightText(dataDoel) & "</td>"
    End If
    End Sub

    Thursday, February 6, 2020 9:20 AM
  • User288213138 posted

    Hi resource18,

    this happens when the linkbutton is hit:
    Protected Sub BewaarDoel_Command(ByVal sender As Object, ByVal e As CommandEventArgs)
    Dim clid As String = e.CommandArgument
    Dim tbNaam As String = Session("tabel")
    Dim datum As Date = txtDatum2.Text
    lestijd1 = dropLestijden.SelectedValue.ToString
    If lestijd1 <> "" Then
    lestijd = Convert.ToInt32(lestijd1)
    Else
    Exit Sub
    End If

    Dim zoekstring As String = ""
    Dim cn As New SqlConnection(Session("verbinding"))
    cn.Open()
    Try
    zoekstring = "IF NOT EXISTS(SELECT agClid from " & tbNaam & " WHERE agClid = '" & clid & "' AND agLkrid = '" & Session("lkrid") & "' and agSchoolid = '" & Session("schoolid") & "' AND lestijd = '" & lestijd & "' AND agDatum = '" & datum.ToString("yyyy/MM/dd") & "' and agAnker = '" & Session("ankernummer") & "') INSERT INTO " & tbNaam & " (agClid) VALUES (@clid)"
    Dim cm As New SqlCommand(zoekstring, cn)
    cm = New SqlCommand(zoekstring, cn)
    cm.Parameters.AddWithValue("@clid", clid)
    cm.ExecuteNonQuery()
    zoekstring = Session("zoekstring")
    If zoekstring <> "" Then
    'openen datareader
    cm = New SqlCommand(zoekstring, cn)
    Dim reader As SqlDataReader = cm.ExecuteReader()
    'bepalen(waarden)
    If reader.HasRows Then
    rptLeerplan.DataSource = reader
    rptLeerplan.DataBind()
    reader.Close()
    Else
    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Geen resultaten bij je zoekactie.');", True)
    End If
    End If
    Catch
    ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Er is een technisch probleem. Foutcode: AGD003.');", True)
    Finally
    cn.Close()
    End Try
    UpdatePanel1.Update()

    End Sub

    And the binding of the repeater:
    Sub Repeater_ItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
    Dim tbNaam As String = Session("tabel")
    Dim labClid As Label = e.Item.FindControl("labClid")
    'arrow
    Dim lnkbtnBewaarDoel As LinkButton = e.Item.FindControl("lnkbtnBewaarDoel")
    LabAantalreg.Text = ""
    Dim dataClid = e.Item.DataItem("clid").ToString
    Dim dataDoel = e.Item.DataItem("cldoel").ToString
    Dim agCount As Integer = 0
    Dim agId As Integer = 0
    Dim zoekString1 As String = ""
    'number
    zoekString1 = "select count(*) as aant from " & tbNaam & " WHERE agClid = '" & dataClid & "' and agSchoolid='" & Session("schoolnummer") & "' AND (agLkrid='" & Session("lkrid") & "' OR (shareLkrid = '" & Session("lkrid") & "' or shareLkrid2 = '" & Session("lkrid") & "' OR shareLkrid3 = '" & Session("lkrid") & "') ) and agDatum >= '" & datum1.ToString("yyyy/MM/dd") & "' and agDatum <= '" & datum2.ToString("yyyy/MM/dd") & "'"
    'DEMOCODE
    Dim cn As New SqlConnection(Session("verbinding"))
    Dim comm As New SqlCommand(zoekString1, cn)
    Dim oSqlAdapter As New SqlDataAdapter(comm)
    Dim oDataSet As New DataSet
    Try
    cn.Open()
    oSqlAdapter.Fill(oDataSet, "resultTable")
    If Integer.Parse(oDataSet.Tables("resultTable").Rows(0).Item("aant")) > 0 Then
    agCount = Integer.Parse(oDataSet.Tables("resultTable").Rows(0).Item("aant"))
    End If
    Catch ex As Exception
    Throw ex
    Finally
    'number text
    LabAantalreg.Text = "<td class='style21' width='1px'>" & agCount & "</td>"
    labDoel.Text = "<td class='style8'>" & HighlightText(dataDoel) & "</td>"
    End If
    End Sub

    I'm very sorry, I still can’t reproduce your problem.

    I checked your code behind and found that some controls are not in your aspx page, and there are still some problems with aspx.

    I think the aspx code should look like below:

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" Width="200px">
                            <ajaxToolkit:TabPanel runat="server" ID="Panel1">
                                <HeaderTemplate>Panel1</HeaderTemplate>
                                <ContentTemplate>
                                    
                                    <asp:Repeater ID="Repeater1" runat="server">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server"></asp:Label>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("child")%>' OnCommand="LinkButton1_Command">LinkButton</asp:LinkButton>
                                            
                                        </ItemTemplate>
                                     </asp:Repeater>      
                                </ContentTemplate>
                            </ajaxToolkit:TabPanel>
                        </ajaxToolkit:TabContainer>
                    </ContentTemplate>
                </asp:UpdatePanel>

    Can you show me your complete code?

    Best regards,

    Sam

    Monday, February 10, 2020 9:47 AM
  • User1294399168 posted

    Hi Sam,

    The labAantal label is a label which is bound in the itembound module and shows a number. This number augments when you clich on the linkbutton.
    I agreed that not all the fields are given in the code because it would be to long. Tere are some fields that I even did not put in the aspx page. It is really a summary. But besides that the only problem is why the update panel rebound from 0 and why the panel does not stay for example on the 14th record. For that you don't need all the code.
    Thanxs anyway that you are interessed !

    Monday, February 10, 2020 2:28 PM
  • User288213138 posted

    Hi resource18,

    The labAantal label is a label which is bound in the itembound module and shows a number. This number augments when you clich on the linkbutton.
    I agreed that not all the fields are given in the code because it would be to long. Tere are some fields that I even did not put in the aspx page. It is really a summary. But besides that the only problem is why the update panel rebound from 0 and why the panel does not stay for example on the 14th record. For that you don't need all the code.

    If it is a tabcontainer problem, you can try to put the updatepanel and repeater control into the tabcontainer, and then test whether the position has changed after the update.

    I tried to reproduce your problem as much as possible, but without success, I tried to put the repeater (with a lot of data) into the tabcontainer, but no scroll bar appeared.

    This is my tested result:

    Best regards,

    Sam

    Tuesday, February 11, 2020 9:02 AM
  • User1294399168 posted

    Thxs for answering the topic.
    I'll try to explain with some screenshots.
    in the working example there is no tabcontainer, only a dataset with an updatepanel. As you can see when I hit the 66th record the value is augmented with one and stays on the 66th position (the scrollbar is on the right side.
    In the not working example (with a tabcontainer a repeater and an updatepanel) I hit the 80th record and the value is augmented with one BUT !!!! it redirects to the first position although there is an updatepanel.
    Is it more clear now????

    Working examplehttps://www.ovsgtoetsen.net/img/working example.jpg

    Tuesday, February 11, 2020 10:49 AM
  • User288213138 posted

    Hi resource18,

    resource18

    I'll try to explain with some screenshots.
    in the working example there is no tabcontainer, only a dataset with an updatepanel. As you can see when I hit the 66th record the value is augmented with one and stays on the 66th position (the scrollbar is on the right side.
    In the not working example (with a tabcontainer a repeater and an updatepanel) I hit the 80th record and the value is augmented with one BUT !!!! it redirects to the first position although there is an updatepanel.
    Is it more clear now????

    I understand the problem you encountered, but I don’t know how you implement the scroll bar in the repeater. Even if I fill a lot of data, the scroll bar does not appear.

    Can show me me your aspx code? If you have too much code, you can simplify your code, as long as it can reproduce your problem

    Best regards,

    Sam

    Thursday, February 13, 2020 6:03 AM
  • User1294399168 posted

    Hi Sam,

    Thxs again for your help.
    The scrollbar is simply a div:

    <asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" OnClientActiveTabChanged="clientActiveTabChanged" BorderStyle="None" TabStripPlacement="TopRight" VerticalStripWidth="100px" UseVerticalStripPlacement="True" BorderColor="Silver">
    <asp:TabPanel runat="server" ID="TabPanel1">
    <HeaderTemplate>
    <div>
    <img src="graphics/boek.gif" alt= "" onmouseover="ddrivetip('Overzicht van de kleuterdoelen(volgens ingestelde leeftijdsfasen).','lightblue', 350)" onmouseout="hideddrivetip()"/><div>Kleuterdoelenboek</div>
    </div>
    </HeaderTemplate>
    <ContentTemplate>
    <td valign ="top">
    <div id="dvScroll" style="Height:500px; Overflow:Auto; ">
    <table width="100%" border="0" align="center" cellpadding="1">
    <tr>
    ....
    </tr>
    </table>
    </div>

    Thursday, February 13, 2020 7:33 AM
  • User288213138 posted

    Hi resource18,

    The scrollbar is simply a div

    I finally reproduced your problem, and then I tried the following code, when I clicked the linkbutton, the position did not change.

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                        <ajaxToolkit:TabContainer ID="TabContainer1" runat="server">
                            <ajaxToolkit:TabPanel runat="server" ID="Panel1">
                                <HeaderTemplate>Panel1</HeaderTemplate>
                                <ContentTemplate>
    
                                    <asp:Panel ID="Panel2" runat="server" ScrollBars="Vertical" Height="300px" Width="620px">
                                        <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                                            <HeaderTemplate>
                                                <table border="1">
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Eval("CustomerId") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("Name") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Eval("Country") %>' />
                                                    </td>
                                                    <td>
                                                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                                            <ContentTemplate>
                                                                   <asp:LinkButton ID="lnkUpdate" Text="Update" runat="server" />                                      
                                                            </ContentTemplate>
                                                            <Triggers>
                                                                <asp:AsyncPostBackTrigger ControlID="lnkUpdate" />
                                                            </Triggers>
                                                        </asp:UpdatePanel>
                                                     
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </asp:Panel>
                                </ContentTemplate>                   
                            </ajaxToolkit:TabPanel>
                        </ajaxToolkit:TabContainer>

    The result:

    Best regards,

    Sam

    Friday, February 14, 2020 9:00 AM
  • User1294399168 posted

    Hi Sam,

    Thxs for the effort but that is not what I want. I need the outside updatepanel also for executing the application faster.
    Anyway I appreciate the help you offered me.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 17, 2020 3:27 PM