Rendere persistente script lato client

giovedì 09 giugno 2005 - 14.50

nandonando Profilo | Senior Member

Ho salvato il mio script in una variabile str e quindi ho fatto Response.Write(str) non sò se è il modo migliore ma funziona
però vorrei sapere se la si può rendere persistente ossia che ad ogni postback non ci sia la necessità di ricrearla
Questo è quello che ho creato:
Dim I As String
Dim n As String
Dim scriptStringPrezzoBase_euro As String = "script language=JavaScript>"
Dim scriptStringPrezzoBase As String
'scriptString += "function ci(){"
scriptStringPrezzoBase_euro += "var PrezzoBase_euro=new Array("
scriptStringPrezzoBase += "var PrezzoBase=new Array("
''''
Dim strsql As String = "select * from tblContratti_tipi"
Dim sqlCommand1 As New SqlCommand(strsql, cn)
Try

cn.Open()
Dim rdrRATA As SqlDataReader = sqlCommand1.ExecuteReader(CommandBehavior.KeyInfo)

While rdrRATA.Read()
I = I & Replace(rdrRATA.Item("PrezzoBase_euro").ToString, ",", ".") & ","
n = n & Replace(rdrRATA.Item("PrezzoBase").ToString, ",", ".") & ","
End While
Catch ex As Exception

End Try
scriptStringPrezzoBase_euro += I
scriptStringPrezzoBase_euro = Mid(scriptStringPrezzoBase_euro, 1, (Len(scriptStringPrezzoBase_euro) - 1))
scriptStringPrezzoBase_euro += ");"
scriptStringPrezzoBase += n
scriptStringPrezzoBase = Mid(scriptStringPrezzoBase, 1, (Len(scriptStringPrezzoBase) - 1))
scriptStringPrezzoBase += ");"
scriptStringPrezzoBase_euro = scriptStringPrezzoBase_euro & scriptStringPrezzoBase
scriptStringPrezzoBase_euro += "</" + "script>"
Response.Write(scriptStringPrezzoBase_euro)

solo che lo devo ricreare ad ogni postbak come posso fare con Page.RegisterArrayDeclaration(...)
scusami ancora


Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5