Rechargement de page apres un clique sur précédent dans le navigateur
Ca fait longtemps que je cherche la soluce.
J'ai essayé plusieurs chose, mais ca ne me convient pas :
- Pragma nocache
- response.cache.setExpires(DateTime.now.AddSeconds(-1))
et d'autre chose.
Je vous presente mon probleme .
Avec le code qui suit, vous comprendrez mieux.
donc, je veux que quand on est sur le default2.aspx, et que l'on revient avec l'history.back (page précédente du navigateur), on recharge la page que l'on recharge le ddl.
C'est pas trop compliqué, peut etre que j'ai mal utilisé le "response.cache.setExpires(DateTime.now.AddSeconds(-1))" mais j'arrive pas au résultat désiré. merci pour vos réponse.
je me demandais si un server.transfert pourrait m'aider. bref... merci d'avance..
Voici les 4 fichiers :
Code:
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
| Option
StrictOn
Imports
Microsoft.VisualBasic
Public
Class enregistrement
Private m_IdEnregistrement As System.Guid = System.Guid.NewGuid
Private m_Enregistrement AsString
PublicProperty IdEnregistrement() As System.Guid
Get
Return m_IdEnregistrement
EndGet
Set(ByVal value As System.Guid)
m_IdEnregistrement = value
EndSet
EndProperty
PublicProperty Enregistrement() AsString
Get
If m_Enregistrement.Length > 50 Then
m_Enregistrement = m_Enregistrement.Substring(0, 49)
EndIf
Return m_Enregistrement
EndGet
Set(ByVal value AsString)
m_Enregistrement = value
EndSet
EndProperty
PublicSubNew(ByVal Enregistrement AsString)
m_Enregistrement = Enregistrement
EndSub
PublicSubNew(ByVal Enregistrement AsString, _
ByVal IdEnregistrement As System.Guid)
m_Enregistrement = Enregistrement
m_IdEnregistrement = IdEnregistrement
EndSub
PublicSubNew()
EndSub
End
Class |
Code:
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| Option
StrictOn
Imports
Microsoft.VisualBasic
Public
Class EnregistrementDataHelper
Private m_strConnectionString AsString = ""
PublicProperty ConnectionString() AsString
Get
If m_strConnectionString = ""Then
m_strConnectionString =
"ma chaine de connexion"
EndIf
Return m_strConnectionString
EndGet
Set(ByVal value AsString)
m_strConnectionString = value
EndSet
EndProperty
Private m_objSqlHelper As SQLHelper
PrivateReadOnlyProperty SqlHelper() As SQLHelper
Get
If m_objSqlHelper IsNothingThen
' Si le SqlHelper n'est pas instancié, on crée une nouvelle instance
m_objSqlHelper =
New SQLHelper(Me.ConnectionString)
EndIf
Return m_objSqlHelper
EndGet
EndProperty
PublicSub InsertEnregistrement(ByVal Enregistrement As enregistrement)
' Execution de l'insertion en base de données
Me.SqlHelper.ExecuteNonQuery(Data.CommandType.StoredProcedure, _
"Enregistrement_INSERT", _
New System.Data.SqlClient.SqlParameter("@Enregistrement", Enregistrement.Enregistrement))
EndSub
PublicFunction Get_Enregistrement_Select() As System.Collections.Generic.List(Of enregistrement)
' Création d'une liste générique de Enregistrement
Dim listEnregistrements AsNew System.Collections.Generic.List(Of enregistrement)
' Récupération de la liste des Enregistrements en base de données
Dim dtEnregistrements As System.Data.DataTable = Me.SqlHelper.GetDataTable(Data.CommandType.StoredProcedure, "Get_Enregistrement_Select")
' Vérification de la présence de Enregistrements
IfNot dtEnregistrements IsNothingThen
ForEach drEnregistrement As System.Data.DataRow In dtEnregistrements.Rows
' Création d'un objet Facure
Dim objEnregistrement AsNew enregistrement(CStr(drEnregistrement("Enregistrement")), _
CType(drEnregistrement("IdEnregistrement"), Guid))
' Ajout à la collection générique des Enregistrement
listEnregistrements.Add(objEnregistrement)
Next
EndIf
Return listEnregistrements
EndFunction
End
Class |
Code:
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
| Option
StrictOn
Imports
Microsoft.VisualBasic
Public
Class SQLHelper
Private m_strConnectionString AsString = ""
PublicProperty ConnectionString() AsString
Get
Return m_strConnectionString
EndGet
Set(ByVal value AsString)
m_strConnectionString = value
EndSet
EndProperty
PublicSubNew(ByVal ConnectionString AsString)
m_strConnectionString = ConnectionString
EndSub
PublicFunction GetDataSet(ByVal CommandType As System.Data.CommandType, _
ByVal CommandText AsString, _
ByValParamArray CommandParameters() As System.Data.SqlClient.SqlParameter) _
As System.Data.DataSet
' Création d'un DataSet
Dim objDataSet AsNew System.Data.DataSet
' Création d'une Connection
Dim objConnection AsNew System.Data.SqlClient.SqlConnection
' Création d'une Command
Dim objCommand AsNew System.Data.SqlClient.SqlCommand
' Création d'un DataAdapter
Dim objAdapter AsNew System.Data.SqlClient.SqlDataAdapter
Try
' Affection de la chaîne de connexion
objConnection.ConnectionString =
Me.ConnectionString
' Ouverture de la Connection
objConnection.Open()
' Affectation de la Connection à la Command
objCommand.Connection = objConnection
' Affectation du type de Command
objCommand.CommandType = CommandType
' Affectation du texte de la Command
objCommand.CommandText = CommandText
IfNot CommandParameters IsNothingThen
' Si les Parameter sont présents, on les ajoute à la Command
ForEach Parameter As System.Data.SqlClient.SqlParameter In CommandParameters
objCommand.Parameters.Add(Parameter)
Next
EndIf
' Affectation de la Command en tant que SelectCommand du DataAdapter
objAdapter.SelectCommand = objCommand
' Récupération du DataSet
objAdapter.Fill(objDataSet)
' Fermeture de la Connection
objConnection.Close()
Catch ex As Exception
Throw
EndTry
Return objDataSet
EndFunction
PublicFunction GetDataTable(ByVal CommandType As System.Data.CommandType, _
ByVal CommandText AsString, _
ByValParamArray CommandParameters() As System.Data.SqlClient.SqlParameter) _
As System.Data.DataTable
' Récupération des résultats
Dim dsResults As System.Data.DataSet = Me.GetDataSet(CommandType, CommandText, CommandParameters)
' Verification du DataSet et des DataTable
IfNot dsResults IsNothingAndAlso _
dsResults.Tables.Count > 0
Then
Return dsResults.Tables(0)
Else
ReturnNothing
EndIf
EndFunction
PublicFunction GetDataRow(ByVal CommandType As System.Data.CommandType, _
ByVal CommandText AsString, _
ByValParamArray CommandParameters() As System.Data.SqlClient.SqlParameter) _
As System.Data.DataRow
' Récupération des résultats
Dim dtResults As System.Data.DataTable = Me.GetDataTable(CommandType, CommandText, CommandParameters)
' Verification de la DataTable et des DataRow
IfNot dtResults IsNothingAndAlso _
dtResults.Rows.Count > 0
Then
Return dtResults.Rows(0)
Else
ReturnNothing
EndIf
EndFunction
PublicFunction ExecuteScalar(ByVal CommandType As System.Data.CommandType, _
ByVal CommandText AsString, _
ByValParamArray CommandParameters() As System.Data.SqlClient.SqlParameter) _
AsObject
' Création d'un Object
Dim objResult AsObject
' Création d'une Connection
Dim objConnection AsNew System.Data.SqlClient.SqlConnection
' Création d'une Command
Dim objCommand AsNew System.Data.SqlClient.SqlCommand
Try
' Affection de la chaîne de connexion
objConnection.ConnectionString =
Me.ConnectionString
' Ouverture de la Connection
objConnection.Open()
' Affectation de la Connection à la Command
objCommand.Connection = objConnection
' Affectation du type de Command
objCommand.CommandType = CommandType
' Affectation du texte de la Command
objCommand.CommandText = CommandText
IfNot CommandParameters IsNothingThen
' Si les Parameter sont présents, on les ajoute à la Command
ForEach Parameter As System.Data.SqlClient.SqlParameter In CommandParameters
objCommand.Parameters.Add(Parameter)
Next
EndIf
' Récupération du résultat
objResult = objCommand.ExecuteScalar
' Fermeture de la Connection
objConnection.Close()
Catch ex As Exception
Throw
EndTry
Return objResult
EndFunction
PublicFunction ExecuteNonQuery(ByVal CommandType As System.Data.CommandType, _
ByVal CommandText AsString, _
ByValParamArray CommandParameters() As System.Data.SqlClient.SqlParameter) _
AsInteger
' Création d'un Integer
Dim intResult AsInteger
' Création d'une Connection
Dim objConnection AsNew System.Data.SqlClient.SqlConnection
' Création d'une Command
Dim objCommand AsNew System.Data.SqlClient.SqlCommand
Try
' Affection de la chaîne de connexion
objConnection.ConnectionString =
Me.ConnectionString
' Ouverture de la Connection
objConnection.Open()
' Affectation de la Connection à la Command
objCommand.Connection = objConnection
' Affectation du type de Command
objCommand.CommandType = CommandType
' Affectation du texte de la Command
objCommand.CommandText = CommandText
IfNot CommandParameters IsNothingThen
' Si les Parameter sont présents, on les ajoute à la Command
ForEach Parameter As System.Data.SqlClient.SqlParameter In CommandParameters
objCommand.Parameters.Add(Parameter)
Next
EndIf
' Récupération du résultat
intResult = objCommand.ExecuteNonQuery
' Fermeture de la Connection
objConnection.Close()
Catch ex As Exception
Throw
EndTry
Return intResult
EndFunction
End
Class |
Code:
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
| <%
@PageLanguage="VB"AutoEventWireup="false"CodeFile="Default.aspx.vb"Inherits="_Default" %>
<!
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
htmlxmlns="http://www.w3.org/1999/xhtml">
<
headrunat="server">
<title>Page sans titre</title>
</
head>
<
body>
<formid="form1"runat="server">
<div>
<asp:LabelID="Label1"runat="server"Text="L'enregistrement"></asp:Label><br/>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><br/>
<br/>
<asp:DropDownListID="DropDownList1"runat="server">
</asp:DropDownList>
<br/>
<br/>
<asp:ButtonID="Button1"runat="server"Text="Button"/></div>
</form>
</
body>
</
html>
-------------------------------------------------------------------------------------------------
Option
StrictOn
Partial
Class _Default
Inherits System.Web.UI.Page
ProtectedSub Page_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMe.Load
Dim EnregistrementDH AsNew EnregistrementDataHelper
Dim listeEnregistement AsNew System.Collections.Generic.List(Of enregistrement)
listeEnregistement = EnregistrementDH.Get_Enregistrement_Select()
Me.DropDownList1.DataSource = listeEnregistement
Me.DropDownList1.DataValueField = "IdEnregistrement"
Me.DropDownList1.DataTextField = "Enregistrement"
Me.DropDownList1.DataBind()
EndSub
ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
Dim EnregistrementDH AsNew EnregistrementDataHelper
Dim Enregistement AsNew enregistrement(Me.TextBox1.Text)
EnregistrementDH.InsertEnregistrement(Enregistement)
Me.Response.Redirect("~/Default2.aspx")
EndSub
End
Class
-------------------------------------------------------------------------------------------------
<%
@PageLanguage="VB"AutoEventWireup="false"CodeFile="Default2.aspx.vb"Inherits="Default2" %>
<!
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
htmlxmlns="http://www.w3.org/1999/xhtml">
<
headrunat="server">
<title>Page sans titre</title>
</
head>
<
body>
<formid="form1"runat="server">
<div>
</div>
</form>
</
body>
</
html> |