IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP.NET Discussion :

Conserver la valeur d'un TextBox lors d'un refreash de la page


Sujet :

ASP.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Août 2007
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 51
    Par défaut Conserver la valeur d'un TextBox lors d'un refreash de la page
    Bonjour,

    J'ai une interface dans laquelle se trouve 2 TextBox et 2 Button (BtnEndStat. Ces Button ouvrir en mode popup des Calendar afin de séléctionner une date. Malheureusement, dès qu'on clique sur un bouton (ex : BtnEndStat) les valeurs des TextBox sont perdues. J'aimerais conserver ces valeurs. Auriez-vous des pistes?
    Je reste à votre dispo pour + d'infos

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    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
     
     
    <asp:textbox id="TxtBeginStat" runat="server" Width="112px" BackColor="Lavender" ReadOnly="True" autopostback="true"></asp:textbox>&nbsp;
    		<A onclick="javascript:window.open('calendar.aspx?call_form=id_Statistics&amp;date='+TxtBeginStat.value+'&amp;txt=TxtBeginStat','popupCalendar','width=275,height=275,left=110,top=200')"
    							href="#">
    							<asp:button 
    							    id="BtnBeginStat" 
    							    style="CURSOR: hand" 
    							    Width="63px" 
                                    BackColor="MintCream" 
                                    CausesValidation="False"
    								Text="Choisir" Runat="server">
    								</asp:button>
    							</A>
    						</td>
    					<td width="40%"><b>à&nbsp;
    						<asp:textbox 
    						    id="TxtEndStat" 
    						    runat="server" 
    						    Width="112px" 
    						    BackColor="Lavender" 
    						    ReadOnly="True"></asp:textbox></b>&nbsp;
    						<A onclick="javascript:window.open('calendar.aspx?call_form=id_Statistics&amp;date='+TxtEndStat.value+'&amp;txt=TxtEndStat','popupCalendar','width=275,height=275,left=110,top=200')"
    						    href="#">
    							<asp:button 
    							    id="BtnEndStat" 
    							    style="CURSOR: hand" 
    							    Width="63px" 
    							    BackColor="MintCream" 
    							    CausesValidation="False"
    								Text="Choisir" 
    								Runat="server"></asp:button></A></td>
    					</td>
    					<td width="20%">
    						<asp:Button 
    						    id="BtnDisplay" 
    						    runat="server" 
    						    Width="92px" 
    						    style="CURSOR: hand" 
    						    BackColor="#C0C0FF"
    							Text="Afficher" 
    							Font-Bold="True" 
    							ForeColor="White"></asp:Button></td>

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    360
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 360
    Par défaut
    vérifies que le Viewstate est activé sur ta page et sur tes TextBox.
    Tu peux aussi empecher tes boutons de faire un PostBack ...

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Août 2007
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 51
    Par défaut
    Citation Envoyé par jjameau Voir le message
    vérifies que le Viewstate est activé sur ta page et sur tes TextBox.
    Tu peux aussi empecher tes boutons de faire un PostBack ...
    Merci pour ta réponse.

    j'ai mis dans les balises <%@ Page %>, <body> et <form>.
    J'ai mis dans les boutons et textbox.

    Les valeurs de textbox continuent tjrs à s'effacer, lorsque la page se rafraîchit (par ex : lors d'un clic sur les boutons ou lors d'un F5)

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    360
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 360
    Par défaut
    peux tu reposter ton code stp

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Août 2007
    Messages
    51
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 51
    Par défaut
    Citation Envoyé par jjameau Voir le message
    peux tu reposter ton code stp
    Bien sûr, voici mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    <%@ Page language="c#" CodeFile="Statistics.aspx.cs" AutoEventWireup="false" Inherits="Gpeto.Statistics" %>
    <%@ Register TagPrefix="uc1" TagName="high_menu" Src="high_menu.ascx" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <html >
    	<HEAD enableviewstate=true>
    		<title>Statistics</title>
    		<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    		<meta content="C#" name="CODE_LANGUAGE">
    		<meta content="JavaScript" name="vs_defaultClientScript">
    		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
     
    	</HEAD>
    	<body enableviewstate="true" >
    		<form id="id_Statistics" method="post" enableviewstate="true" runat="server" >
    			<P>&nbsp;</P>
    			<table width="85%" align="center" border="0">
    				<tr>
    					<td align="center" colSpan="3"><asp:label id="Label1" runat="server" Font-Bold="True" Font-Size="Large">Statistiques des versions</asp:label></td>
    				</tr>
    				<tr>
    					<td colSpan="3">&nbsp;</td>
    				</tr>
    				<tr>
    					<td colSpan="3">&nbsp;</td>
    				</tr>
    				<tr>
    					<td width="40%"><b>De</b>&nbsp;
    						<asp:textbox id="TxtBeginStat" 
    						    runat="server" 
    						    Width="112px" 
    						    EnableViewState="false"
    						    ReadOnly="true"
                                BackColor="Lavender" 
                                autopostback="false"></asp:textbox>&nbsp;
    						<A onclick="javascript:window.open('calendar.aspx?call_form=id_Statistics&amp;date='+TxtBeginStat.value+'&amp;txt=TxtBeginStat','popupCalendar','width=275,height=275,left=110,top=200')"
    							href="#">
    							<asp:button 
    							    id="BtnBeginStat" 
    							    style="CURSOR: hand" 
    							    Width="63px" 
                                    BackColor="MintCream" 
                                    CausesValidation="False"
                                    autopostback="false"
     
    								Text="Choisir" 
    								Runat="server" UseSubmitBehavior="False" onclick="BtnBeginStat_Click">
    								</asp:button>
    							</A>
    						</td>
    					<td width="40%"><b>à&nbsp;
    						<asp:textbox 
    						    id="TxtEndStat" 
    						    runat="server" 
    						    Width="112px" 
    						    BackColor="Lavender" 
    						    EnableViewState="false"
    						    autopostback="false" ReadOnly="True"></asp:textbox></b>&nbsp;
    						<A onclick="javascript:window.open('calendar.aspx?call_form=id_Statistics&amp;date='+TxtEndStat.value+'&amp;txt=TxtEndStat','popupCalendar','width=275,height=275,left=110,top=200')"
    						    href="#">
    							<asp:button 
    							    id="BtnEndStat" 
    							    style="CURSOR: hand" 
    							    Width="63px" 
    							    BackColor="MintCream" 
    							    CausesValidation="False"
    							    autopostback="false"
    								Text="Choisir" 
    								Runat="server" 
    								UseSubmitBehavior="False" 
    								onclick="BtnEndStat_Click"></asp:button></A></td>
    					</td>
    					<td width="20%">
    						<asp:Button 
    						    id="BtnDisplay" 
    						    runat="server" 
    						    Width="92px" 
    						    style="CURSOR: hand" 
    						    BackColor="#C0C0FF"
    							Text="Afficher" 
    							Font-Bold="True" 
    							ForeColor="White"></asp:Button></td>
    				</tr>
    Je suis en train de chercher sur le WEB il y semble qu'il y aurait un rapport avec le fait que les TextBox soient en

  6. #6
    Membre très actif
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Février 2007
    Messages
    871
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Février 2007
    Messages : 871
    Par défaut
    c'est: vu que les textBox sont en readOnly .net comprend qu'il n' y pas besoin de stocker en viewstate leurs infos, c'est balot:
    http://www.codeproject.com/KB/aspnet/Readonly.aspx

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 13
    Dernier message: 24/05/2011, 20h38
  2. Réponses: 4
    Dernier message: 21/05/2011, 17h45
  3. Réponses: 1
    Dernier message: 01/10/2010, 17h51
  4. Réponses: 2
    Dernier message: 04/02/2009, 20h50
  5. Réponses: 8
    Dernier message: 17/05/2006, 12h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo