Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何在单个会话对象中跨不同页面存储多个字段值_Asp.net_Vb.net - Fatal编程技术网

Asp.net 如何在单个会话对象中跨不同页面存储多个字段值

Asp.net 如何在单个会话对象中跨不同页面存储多个字段值,asp.net,vb.net,Asp.net,Vb.net,如何在单个会话对象中跨不同页面存储多个字段值,并触发该会话,以便在最后一页单击按钮保存数据库中的所有字段值。一小段代码会有所帮助 我认为您应该将所有这些字段值保存在一个类中,并将该类对象直接存储在会话中。虽然您的问题有点含糊不清,但我将根据我的理解回答。这是在会话对象中存储值所必须执行的操作: 'a string on an aspx page Me.Session("Value1") = "My String" 'an integer on some other asp

如何在单个会话对象中跨不同页面存储多个字段值,并触发该会话,以便在最后一页单击按钮保存数据库中的所有字段值。一小段代码会有所帮助

我认为您应该将所有这些字段值保存在一个类中,并将该类对象直接存储在会话中。

虽然您的问题有点含糊不清,但我将根据我的理解回答。这是在
会话
对象中存储值所必须执行的操作:

    'a string on an aspx page
    Me.Session("Value1") = "My String"
    'an integer on some other aspx page
    Me.Session("Value2") = 100
    'a different string of yet another different aspx page
    Me.Session("Value3") = "Another String"
然后,在单击按钮的页面上,可以获得如下值:

Dim str1 As String = Convert.ToString(Me.Session("Value1"))
Dim myInt As Integer = Convert.ToInt32(Me.Session("Value1"))
Dim str2 As String = Convert.ToString(Me.Session("Value3"))

请注意,我使用了不同的变量来存储这些值。这只是为了让您了解事物是如何工作的,但拥有一个自定义对象而不是使用许多不同的对象将是一个很好的方法。

我也这么认为。谢谢你的回复。我想知道怎么做。一段代码会有帮助。以下回复是否解决了您的问题?如果是,请将其标记为答案,以便您的问题不会保留在未回答问题类别中。谢谢