0

i have repeater that show questions and 4 option of answer , i want i can't abel to show CorrectAnswer after one minute

Note: Writing the question in the stackoverflow took me a lot of time, I hope to find a solution to my problem

THis my markup:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Label ID="lblTime" runat="server" />
        <br />
        <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
            <ItemTemplate >
                <div class="panel-heading">
                    <div class="panel-title btn-label q-border">
                          <h3 class="Golden-color"><span class="label label-success" style="margin-left:10px;" id="qid"><%# Eval("Category") %></span><%# Eval("Question") %></h3>
                    </div>
                    <h2 id="counter" class="Golden-color"></h2>
                </div>
                <div class="panel-body card ">
          <div class="quiz" id="quiz" data-toggle="buttons">
           <label class="element-animation1 btn btn-lg btn-transparent btn-block"><span class="btn-label"><i class="glyphicon">A</i></span> <input type="radio" name="q_answer" value="1">
               <%# Eval("OptionA") %>
           </label>
           <label class="element-animation2 btn btn-lg btn-transparent btn-block"><span class="btn-label"><i class="glyphicon">B</i></span> <input type="radio" name="q_answer" value="2">
               <%# Eval("OptionB") %>
           </label>
           <label class="element-animation3 btn btn-lg btn-transparent btn-block"><span class="btn-label"><i class="glyphicon">C</i></span> <input type="radio" name="q_answer" value="3">
               <%# Eval("OptionC") %>
           </label>
           <label class="element-animation4 btn btn-lg btn-transparent btn-block"><span class="btn-label"><i class="glyphicon">D</i></span> <input type="radio" name="q_answer" value="4">
                <%# Eval("OptionD") %>
           </label>
              <asp:Label ID="LblCorrectAnswer" runat="server" Visible="false" Text='<%#Eval("CorrectAnswer")%>' CssClass="label label-success"></asp:Label>
       </div>
   </div>
            </ItemTemplate>
        </asp:Repeater>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>"
            SelectCommand="SELECT TOP 1 * FROM Questions ORDER BY NEWID()"></asp:SqlDataSource>
        <asp:Timer ID="Timer1" runat="server" OnTick="TimerTick" Interval="10000" Enabled ="true"  />
    </ContentTemplate>
</asp:UpdatePanel>


 Protected Sub TimerTick(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
        If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim lbl As Label = TryCast(e.Item.FindControl("LblCorrectAnswer"), Label)
            lbl.Visible = True
        End If
        Timer1.Enabled = False
    End Sub
Haytham
  • 1
  • 2
  • Possible duplicate of [Unable to find ASP Repeater child control from ASP Timer tick event](https://stackoverflow.com/questions/16788655/unable-to-find-asp-repeater-child-control-from-asp-timer-tick-event) – Kate Orlova Jul 20 '19 at 19:07

1 Answers1

0

just add this below contenttemplate inside update panel

  <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
  </Triggers>