Foros del Web » Programación para mayores de 30 ;) » .NET »

[SOLUCIONADO] pasar datos de un aspx a otro

Estas en el tema de pasar datos de un aspx a otro en el foro de .NET en Foros del Web. Hola, Tengo problemas a la hora de pasar datos de una aspx a otra. en un principio lo hacia así: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código vb.net: Ver ...
  #1 (permalink)  
Antiguo 24/05/2013, 03:19
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
pasar datos de un aspx a otro

Hola,

Tengo problemas a la hora de pasar datos de una aspx a otra. en un principio lo hacia así:
Código vb.net:
Ver original
  1. Response.Redirect(String.Format("ValidarHoja.aspx?identificador={0}&nombre={1}&codigolinea={2}&ceco={3}&orden={4}" & _
  2. "&proyecto={5}&fecha={6}&facturable={7}&importeTotal={8}" & _
  3. "&importekm={9}&elementopepkm={10}&cuentakm={11}" & _
  4. "&importeap={12}&elementopepap={13}&cuentaap={14}" & _
  5. "&importepark={15}&elementopeppark={16}&cuentapark={17}" & _
  6. "&importealoj={18}&elementopepaloj={19}&cuentaaloj={20}" & _
  7. "&importebitrans={21}&elementopepbitrans={22}&cuentabitrans={23}" & _
  8. "&importevehi={24}&elementopepvehi={25}&cuentavehi={26}" & _
  9. "&importecomb={27}&elementopepcomb={28}&cuentacomb={29}",
  10. hoja, nombre, codigolinea, ceco, orden,
  11. Me.TxtProyectoVRLG.Text, fechaformato, Me.RadioButtonFacturableVRLG.SelectedItem.Value, Me.TextTotGastosCantiVRLG.Text,
  12. importekm, Me.TextElementoPepKmVRLG.Text, cuentaKm,
  13. importeap, Me.TextElementoPepApVRLG.Text, cuentaAp,
  14. importepark, Me.TextElementoPepParkVRLG.Text, cuentaParking,
  15. importealoj, Me.TextElementoPepAlojVRLG.Text, cuentaAlojamiento,
  16. importebi, Me.TextElementoPepBiTransVRLG.Text, cuentaBiTrans,
  17. importealki, Me.TextElementoPepAlVehiVRLG.Text, cuentaAlVehi,
  18. importecomb, Me.TextElementoPepComVehiVRLG.Text, cuentaCombustible))

Pero como veis esto se reflejaria en la barra de direcciones y no kiero que se refleje. Para ello cree una clase llamada DatosG.vb en la que tengo lo siguiente:
Código vb.net:
Ver original
  1. Public Class DatosG
  2.     Public Property importekm() As Decimal
  3.         Get
  4.             Return m_importekm
  5.         End Get
  6.         Set(ByVal value As Decimal)
  7.             m_importekm = value
  8.         End Set
  9.     End Property
  10.     Private m_importekm As Decimal
  11.  
  12.     Public Property importeap() As Decimal
  13.         Get
  14.             Return m_importeap
  15.         End Get
  16.         Set(ByVal value As Decimal)
  17.             m_importeap = value
  18.         End Set
  19.     End Property
  20.     Private m_importeap As String
  21.  
  22.     Public Property importepark() As Decimal
  23.         Get
  24.             Return m_importepark
  25.         End Get
  26.         Set(ByVal value As Decimal)
  27.             m_importepark = value
  28.         End Set
  29.     End Property
  30.     Private m_importepark As Decimal
  31.  
  32.     Public Property importealoj() As Decimal
  33.         Get
  34.             Return m_importealoj
  35.         End Get
  36.         Set(ByVal value As Decimal)
  37.             m_importealoj = value
  38.         End Set
  39.     End Property
  40.     Private m_importealoj As Decimal
  41.  
  42.     Public Property importebi() As Decimal
  43.         Get
  44.             Return m_importebi
  45.         End Get
  46.         Set(ByVal value As Decimal)
  47.             m_importebi = value
  48.         End Set
  49.     End Property
  50.     Private m_importebi As Decimal
  51.  
  52.     Public Property importealki() As Decimal
  53.         Get
  54.             Return m_importealki
  55.         End Get
  56.         Set(ByVal value As Decimal)
  57.             m_importealki = value
  58.         End Set
  59.     End Property
  60.     Private m_importealki As Decimal
  61.  
  62.     Public Property importecomb() As Decimal
  63.         Get
  64.             Return m_importecomb
  65.         End Get
  66.         Set(ByVal value As Decimal)
  67.             m_importecomb = value
  68.         End Set
  69.     End Property
  70.     Private m_importecomb As Decimal
  71.  
  72.     Public Property importemanu() As Decimal
  73.         Get
  74.             Return m_importemanu
  75.         End Get
  76.         Set(ByVal value As Decimal)
  77.             m_importemanu = value
  78.         End Set
  79.     End Property
  80.     Private m_importemanu As Decimal
  81.  
  82.     Public Property importerela() As Decimal
  83.         Get
  84.             Return m_importerela
  85.         End Get
  86.         Set(ByVal value As Decimal)
  87.             m_importerela = value
  88.         End Set
  89.     End Property
  90.     Private m_importerela As String
  91.  
  92.     Public Property importeotros() As Decimal
  93.         Get
  94.             Return m_importeotros
  95.         End Get
  96.         Set(ByVal value As Decimal)
  97.             m_importeotros = value
  98.         End Set
  99.     End Property
  100.     Private m_importeotros As Decimal
  101.  
  102.     Public Property importesub() As Decimal
  103.         Get
  104.             Return m_importesub
  105.         End Get
  106.         Set(ByVal value As Decimal)
  107.             m_importesub = value
  108.         End Set
  109.     End Property
  110.     Private m_importesub As Decimal
  111.  
  112.     Public Property importeferi() As Decimal
  113.         Get
  114.             Return m_importeferi
  115.         End Get
  116.         Set(ByVal value As Decimal)
  117.             m_importeferi = value
  118.         End Set
  119.     End Property
  120.     Private m_importeferi As Decimal
  121.  
  122.     Public Property importeregla() As Decimal
  123.         Get
  124.             Return m_importeregla
  125.         End Get
  126.         Set(ByVal value As Decimal)
  127.             m_importeregla = value
  128.         End Set
  129.     End Property
  130.     Private m_importeregla As Decimal
  131.  
  132.     Public Property importecata() As Decimal
  133.         Get
  134.             Return m_importecata
  135.         End Get
  136.         Set(ByVal value As Decimal)
  137.             m_importecata = value
  138.         End Set
  139.     End Property
  140.     Private m_importecata As Decimal
  141.  
  142.     Public Property importeinter() As Decimal
  143.         Get
  144.             Return m_importeinter
  145.         End Get
  146.         Set(ByVal value As Decimal)
  147.             m_importeinter = value
  148.         End Set
  149.     End Property
  150.     Private m_importeinter As Decimal
  151.  
  152.     Public Property importegastexcep() As Decimal
  153.         Get
  154.             Return m_importegastexcep
  155.         End Get
  156.         Set(ByVal value As Decimal)
  157.             m_importegastexcep = value
  158.         End Set
  159.     End Property
  160.     Private m_importegastexcep As Decimal
  161. End Class

Y al darle a un boton de mi aplicacion lo que hago es lo siguiente:
Código vb.net:
Ver original
  1. Dim datoG As New DatosG()
  2.         datoG.importekm = CDec(Me.TextImporteKmVRLG.Text)
  3.         datoG.importeap = CDec(Me.TextImporteApVRLG.Text)
  4.         datoG.importepark = CDec(Me.TextImporteParkVRLG.Text)
  5.         datoG.importealoj = CDec(Me.TextImporteAlojVRLG.Text)
  6.         datoG.importebi = CDec(Me.TextImporteBiTransVRLG.Text)
  7.         datoG.importealki = CDec(Me.TextImporteAlVehiVRLG.Text)
  8.         datoG.importecomb = CDec(Me.TextImporteComVehiVRLG.Text)

Y para recogerlos no hace falta nada mas que poner lo siguiente:
Código vb.net:
Ver original
  1. Dim datoG As DatosG = TryCast(Session("datosG"), DatosG)
  2. importekm = datoG.importekm


No se por que me da error a la hora de recoger los valores. Es como si no se guardarian.

¿Alguien me puede ayudar?
__________________
Gracias por todo;

Un saludo
  #2 (permalink)  
Antiguo 24/05/2013, 03:24
Avatar de Malenko
Moderador
 
Fecha de Ingreso: enero-2008
Mensajes: 5.323
Antigüedad: 16 años, 3 meses
Puntos: 606
Respuesta: pasar datos de un aspx a otro

Puedes seguir pasandolos como cadena (querystring) pero encriptandolos. Aqui tienes un mecanismo muy sencillo de encriptar la querystring para pasar información sensible entre dos aspx:

http://geeks.ms/blogs/gperez/archive...-cilmente.aspx
__________________
Aviso: No se resuelven dudas por MP!
  #3 (permalink)  
Antiguo 24/05/2013, 05:50
 
Fecha de Ingreso: abril-2012
Mensajes: 449
Antigüedad: 12 años, 1 mes
Puntos: 7
Respuesta: pasar datos de un aspx a otro

Ya lo he solucionado.
a la hora de añadir los valores donde hago lo siguiente:
Código vb.net:
Ver original
  1. Dim datoG As New DatosG()
  2. datoG.importetotal = CDec(Me.TextTotGastosCantiVRLG.Text)
  3. datoG.importekm = CDec(Me.TextImporteKmVRLG.Text)
  4. datoG.importeap = CDec(Me.TextImporteApVRLG.Text)

Me faltaba añadir esto:
Código vb.net:
Ver original
  1. Session.Add("datosG", datoG)

Gracias Malenko por tu respuesta.

Saludos
__________________
Gracias por todo;

Un saludo

Etiquetas: aspx, vb
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:25.