Bonjour à tous,
Je cherche à réaliser un questionnaire qui « tourne » au fur et à mesure des réponses.
Le problème, est que sur l’évènement OnClick de mon bouton (qui est sensé rafraîchir l’update panel) je parviens à afficher la msgbox contenu dans le pageload (normalement uniquement au chargement de la page nan ?), et donc que mon compteur se réinitialise…


Un peu de code sera surement plus parlant:
VB (behind)
ASP
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49Imports System.Data.Odbc Public Class quizz Inherits System.Web.UI.Page Dim DataTable As New DataTable Dim dtCount As New Integer Dim numQ As New Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load MsgBox("REVIEN ICI ?") DataTable = initQuizz() dtCount = DataTable.Rows.Count numQ = 0 If (dtCount > numQ) Then viewQuestion(DataTable, numQ) Else Response.Redirect("..\------------.aspx") End If End Sub Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click numQ = numQ + 1 viewQuestion(DataTable, numQ) MsgBox("numQ") End Sub Private Sub viewQuestion(ByVal dt As DataTable, ByVal i As Integer) lblQuestion.Text = dt.Rows(i).ItemArray(1) lblDescriQuestion.Text = dt.Rows(i).ItemArray(2) End Sub Function initQuizz() -> ici je vais ds ma BD et récup mes info (sa marche pas de pb) End Function 'Private Function currentQuestion(ByVal numQ As Integer) 'MsgBox("save des info courrant") 'MsgBox(numQ) 'If (numQ < dtCount) Then 'numQ = numQ + 1 'Return numQ 'Else 'MsgBox("fin du questionnaire") 'End If 'Return Nothing 'End Function End Class
(En gros j’affiche Q1 après je click sur « Save » et j’affiche Q2. Par la suite, mon compteur ne dépasse pas Q2
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnSave" /> </Triggers> <ContentTemplate> <fieldset> <legend> QUESTIONNAIRE</legend> <hr /> <asp:Label ID="lblInfos" runat="server" Text="PréInfos"></asp:Label><br /> <asp:Label ID="lblQuestion" runat="server" Text="Question"></asp:Label><br /> <asp:Label ID="lblDescriQuestion" runat="server" Text="desc"></asp:Label><br /> <asp:RadioButton ID="RadioButton1" runat="server" /> <asp:RadioButton ID="RadioButton2" runat="server" /> <asp:RadioButton ID="RadioButton3" runat="server" /> <asp:RadioButton ID="RadioButton4" runat="server" /><br /> <asp:TextBox ID="txtExplain" runat="server" Rows="5" style="margin-top: 0px"></asp:TextBox> <br /> </fieldset> </ContentTemplate> </asp:UpdatePanel> <asp:Button ID="btnSave" runat="server" Text="save" /> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> ...updating... </ProgressTemplate> </asp:UpdateProgress>)
Je ne comprends pas, peut-être que cela vient du fait que mon incrémentation se fait au sein d’une fonction et qu’elle est donc annulé à la fin de celle si… pourtant ma variable est déclaré en globale…
Merci d’avance de vos réponses !
Boulouk_22

 

 
		
		 
         
 

 
			
			

 
   


 Incrémentation dans UpdatePanel
 Incrémentation dans UpdatePanel
				
 Répondre avec citation
  Répondre avec citation
Partager