Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Update Panel is not refreshed + controls of can't generate events

$
0
0

Hi everyone...

Can anybody help me, why any of the control bentween <ContentTemplate> </ContentTemplate> can't cause event..

Textbox and Listboxes are not updated when i click on any control with in <ContentTemplate> </ContentTemplate>

Source code of my page is as below...

<body>
    <form id="form1" runat="server">
    <!--******************************************  header division   ******************************************-->
    <div id="div1" runat="server" style="position: absolute; top: 0%; height: 10%; background-color: #FFB3FF;
        font-family: Arial Narrow; overflow: hidden; color: Blue; left: 1%; width: 92%;">
             // heading text
    </div>
    <!--******************************************  timer division   ******************************************-->
    <div id="div4" runat="server" style="position: absolute; top: 0%; height: 10%; left: 92%;
        background-color: White; overflow: hidden; color: Blue; width: 7%;">
       

       <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Timer ID="Timer1" runat="server" Interval="1000">
                </asp:Timer>
                <asp:Label ID="lblmin" runat="server"> </asp:Label>
                &nbsp;:
                <asp:Label ID="lblsec" runat="server"> </asp:Label>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
   

<!--******************************************  main division division   ******************************************-->
    <div id="div2" runat="server" style="position: absolute; height: 85%; background-color: White;
        top: 10%; left: 1%; width: 98%;">
    

    <asp:UpdatePanel ID="UpdaePanel2" runat="server">
    

        <ContentTemplate>
                <!----------  left division for quick navigation of questions   --------->
                <asp:Panel runat="server" ID="subdiv1" Style="position: absolute; left: 0%; width: 15%;
                    overflow: auto; height: 100%;">
                    Quick Selection of Question
                    <asp:ListBox ID="ListQuestNo" runat="server" AutoPostBack="true" Width="100%"></asp:ListBox>
                </asp:Panel>
    

            <!----------  right division for questions to render   --------->
                <asp:Panel runat="server" ID="Div5" Style="position: absolute; left: 15%; width: 83%;
                    overflow: auto; text-align: left; height: 100%;">
                    <table style="width: 100%; position: absolute;">
                        <tr>
                            <td>
                                <asp:Button ID="v1btnPrev" runat="server" Text="<== Previous" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                                &nbsp;&nbsp;
                                <asp:Button ID="v1btnNext" runat="server" Text="Next ==>" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                                &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
                                <asp:Button ID="v1btnEndTest" runat="server" Text="End Test" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox TextMode="MultiLine" Width="90%" Height="300px" ID="v1txtQuestion" ForeColor="Black"
                                    Font-Size="X-Large" ReadOnly="true" runat="server">
                                </asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:ListBox ID="v1ListOptions" Width="90%" runat="server" AutoPostBack="true"></asp:ListBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="Button1" runat="server" Text="<== Previous" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                                &nbsp;&nbsp;
                                <asp:Button ID="Button2" runat="server" Text="Next ==>" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                                &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;
                                <asp:Button ID="Button3" runat="server" Text="End Test" ForeColor="White" Font-Size="Large"
                                    BackColor="#9393FF" CausesValidation="false" Font-Names="Arial Narrow" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Label ID="v1lblerror" runat="server" Text=""></asp:Label>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </ContentTemplate>
    

        <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ListQuestNo" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="v1btnPrev" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="v1btnNext" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="v1btnEndTest" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
            </Triggers>
    

    </asp:UpdatePanel>   

</div>

    <!--******************************************  footer division   ******************************************-->
    <div id="div3" runat="server" style="position: absolute; height: 5%; background-color: #FFB3FF;
        overflow: hidden; color: Blue; font-family: Arial Narrow; bottom: 0%; left: 1%;
        width: 98%;">

                 //labels to display footers
    </form>
</body>

When page is loaded for first time, Timer works properly...

when i change index of Listbox, Timer gets stop.....

Can anyone tell me whats problem in above code ??

==== Code Behind =========

Imports System.IO
Imports System.Data.OleDb

Partial Class Test
    Inherits System.Web.UI.Page
    Public ObjCon As New ConClass

   'variable declarations.....

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

         If Not IsPostBack Then

          //this segment fills Listbox, which contains numbers of questions.... so that randomly navigation from 1 que to another can become possible

           ListQuestNo.Rows = Integer.Parse(Session("OptPattern").ToString().Length.ToString())
            For i = 1 To Session("OptPattern").ToString.Length
                ListQuestNo.Items.Add(i.ToString())
            Next
            ListQuestNo.SelectedIndex = 0
            SetQuestion(1)
        End If

    End Sub

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim min, sec As Integer


        min = Session("min")
        sec = Session("sec")

        If (min = 0 And sec = 0) Then
            StoreScore() // stores score in database
            Response.Redirect("~\Student.aspx")
        Else
            sec = sec - 1
            If (sec < 0) Then
                sec = 59
                min = min - 1
            End If
            Session("min") = min
            Session("sec") = sec
            lblmin.Text = Session("min").ToString()
            lblsec.Text = Session("sec").ToString()
        End If

    End Sub

    Public Sub StoreScore()

                 //calculates score and stores in Database

    End Sub


    Public Function GetScore() As Integer

        Dim score As Integer = 0

                      //calculate score and return to calling function


        Return score
    End Function

// this Sub sets Textbox which will contain actual question + Fill Listbox with options of that question + set the index of Listbox if once you have answerd that same question...
    Protected Sub SetQuestion(ByVal Qno As Integer)
        v1lblerror.Text = ""
        Dim totalOpt As Integer = Integer.Parse(Session("OptPattern").ToString().Chars(Qno - 1).ToString())
        Dim i As Integer
        Dim index As Integer = 0
        Try
            v1ListOptions.Items.Clear()
            If File.Exists(TestPath + Session("TestNo").ToString() + "_" + Qno.ToString() + ".txt") = True Then
                v1txtQuestion.Text = File.ReadAllText(TestPath + Session("TestNo").ToString() + "_" + Qno.ToString() + ".txt")
            End If
            v1ListOptions.Rows = totalOpt
            v1ListOptions.Items.Add(File.ReadAllText(TestPath + Session("TestNo").ToString() + "_" + Qno.ToString() + "_1.txt").ToString())
            v1ListOptions.Items.Add(File.ReadAllText(TestPath + Session("TestNo").ToString() + "_" + Qno.ToString() + "_2.txt").ToString())

            i = 3
            While (i <= totalOpt)
                v1ListOptions.Items.Add(File.ReadAllText(TestPath + Session("TestNo").ToString() + "_" + Qno.ToString() + "_" + i.ToString() + ".txt").ToString())
                i = i + 1
            End While

            index = Integer.Parse(Session("SPattern").ToString().Substring((Qno - 1), 1))
            index = index - 1
            v1ListOptions.SelectedIndex = index
        Catch ex As Exception
            v1lblerror.Text = ex.Message
        Finally

        End Try

    End Sub


    Protected Sub ListQuestNo_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListQuestNo.SelectedIndexChanged
        Dim Qno As Integer = Integer.Parse(ListQuestNo.SelectedItem.Text.ToString())
        SetQuestion(Qno)
    End Sub


    Protected Sub v1btnEndTest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles v1btnEndTest.Click, Button3.Click
        StoreScore()
        Response.Redirect("~\Student.aspx")
    End Sub

    Protected Sub v1btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles v1btnNext.Click, Button2.Click
        If ListQuestNo.SelectedIndex = ListQuestNo.Rows - 1 Then
            ListQuestNo.SelectedIndex = 0
        Else
            ListQuestNo.SelectedIndex = ListQuestNo.SelectedIndex + 1
        End If
        SetQuestion(Integer.Parse(ListQuestNo.SelectedItem.Text.ToString()))
    End Sub


    Protected Sub v1btnPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles v1btnPrev.Click, Button1.Click
        If ListQuestNo.SelectedIndex = 0 Then
            ListQuestNo.SelectedIndex = ListQuestNo.Rows - 1
        Else
            ListQuestNo.SelectedIndex = ListQuestNo.SelectedIndex - 1
        End If
        SetQuestion(Integer.Parse(ListQuestNo.SelectedItem.Text.ToString()))

    End Sub

// this list box contains options of question..
    Protected Sub v1ListOptions_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles v1ListOptions.SelectedIndexChanged
        Session("SPattern") = Session("SPattern").ToString().Insert((ListQuestNo.SelectedIndex + 1), (v1ListOptions.SelectedIndex + 1).ToString)
        Session("SPattern") = Session("SPattern").ToString().Remove(ListQuestNo.SelectedIndex, 1)
    End Sub
End Class


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>