473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Writing Session Variable Information To a Table

I have a four page form. Pages 1-3 stores there information in a session
variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get it
to show up in the right place. For example I use this code in the HTML
table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1 has not
been declared. Can I use session variables this way to display the
information?
Nov 17 '05 #1
5 1968
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So it
will vary the amount of information that will be displayed on the summary
page. If I put all these label fields in that cell of the table, it will
space it out and leave a huge gap. What I was looking to for was something
that would allow the cell to conform to the amount of information that will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Michelle,

No, that isn't the proper way to use them.

I would put a label into the table and then when you get to the page set the text of the label = to the session variable.

(e.g.

Label1.Text = CType(Session("var1"), String)

)

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get

it
to show up in the right place. For example I use this code in the HTML
table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1 has

not
been declared. Can I use session variables this way to display the
information?


Nov 17 '05 #2
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So it will vary the amount of information that will be displayed on the summary
page. If I put all these label fields in that cell of the table, it will
space it out and leave a huge gap. What I was looking to for was something that would allow the cell to conform to the amount of information that will be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Michelle,

No, that isn't the proper way to use them.

I would put a label into the table and then when you get to the page set

the
text of the label = to the session variable.

(e.g.

Label1.Text = CType(Session("var1"), String)

)

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:uF**************@TK2MSFTNGP12.phx.gbl...
I have a four page form. Pages 1-3 stores there information in a session variables. Page four is reached (a final review page) and then the
information will be written to the SQL server.

When I tried to enter some code in the HTML table by hand so I could get
it
to show up in the right place. For example I use this code in the
HTML table:

<td><%=sessionvar1%><%=sessionvar2%></td>

Compile and run, when I get to the 4th page it says that sessionvar1

has not
been declared. Can I use session variables this way to display the
information?



Nov 17 '05 #3
Let me add some code:

Here is the code behind page: (I know this might not be the most efficent
way )

An if statement checks what check boxes were checked and displays them to
the correct label in the table:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("Gifttoag") Then
Me.Label1.Text = "College of Agriculture"
Else
Me.Label1.Text = ""
End If
If Session("Gifttobus") Then
Me.Label2.Text = "College of Buisness "
Else
Me.Label2.Text = ""
End If
If Session("Gifttodesign") Then
Me.Label3.Text = "College of Design"
Else
Me.Label3.Text = ""
End If
If Session("Gifttoedu") Then
Me.Label4.Text = "College of Education"
Else
Me.Label4.Text = ""
End If
If Session("Gifttoengin") Then
Me.Label5.Text = "College of Engineering"
Else
Me.Label5.Text = ""
End If
If Session("Gifttofcs") Then
Me.Label6.Text = "College of Family and Consumer Sciences"
Else
Me.Label6.Text = ""
End If
If Session("Gifttolas") Then
Me.Label7.Text = "College of Liberal Arts and Sciences"
Else
Me.Label7.Text = ""
End If
If Session("Gifttovetmed") Then
Me.Label8.Text = "College of Veterinary Medicine"
Else
Me.Label8.Text = ""
End If
If Session("Gifttolibrary") Then
Me.Label9.Text = "University Library"
Else
Me.Label9.Text = ""
End If
If Session("Gifttomorrill") Then
Me.Label10().Text = "Morrill Hall Restoration Project"
Else
Me.Label10.Text = ""
End If
If Session("Gifttoarea") Then
Me.Label11().Text = "Area of Greatest Need"
Else
Me.Label11.Text = ""
End If

Me.Label12.Text = Session("Gifttoother")
Me.Label13.Text = Session("GiftAmount")
End Sub
Here is the HTML section where the information is displayed in the table.

<tr>
<td style="WIDTH: 268px; HEIGHT: 21px" align="left">Gift
Desgination(s):</td>
<td align="center" style="HEIGHT: 21px">

<asp:Label id="Label1" runat="server">Label</asp:Label>

<asp:label id="Label2" runat="server">Label</asp:label>
<asp:label id="Label3" runat="server">Label</asp:label>
<asp:label id="Label4" runat="server">Label</asp:label>
<asp:label id="Label5" runat="server">Label</asp:label>
<asp:label id="Label6" runat="server">Label</asp:label>
<asp:label id="Label7" runat="server">Label</asp:label>
<asp:label id="Label8" runat="server">Label</asp:label>
<asp:Label id="Label9" runat="server">Label</asp:Label>
<asp:Label id="Label10" runat="server">Label</asp:Label>
<asp:Label id="Label11" runat="server">Label</asp:Label>
<asp:Label id="Label12" runat="server">Label</asp:Label>
</td>
</tr>

"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So
it
will vary the amount of information that will be displayed on the summary page. If I put all these label fields in that cell of the table, it will space it out and leave a huge gap. What I was looking to for was

something
that would allow the cell to conform to the amount of information that

will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
> Michelle,
>
> No, that isn't the proper way to use them.
>
> I would put a label into the table and then when you get to the page set the
> text of the label = to the session variable.
>
> (e.g.
>
> Label1.Text = CType(Session("var1"), String)
>
> )
>
> Sincerely,
>
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Michelle A." <me@me.com> wrote in message
> news:uF**************@TK2MSFTNGP12.phx.gbl...
> > I have a four page form. Pages 1-3 stores there information in a
session
> > variables. Page four is reached (a final review page) and then the > > information will be written to the SQL server.
> >
> > When I tried to enter some code in the HTML table by hand so I could get
> it
> > to show up in the right place. For example I use this code in the

HTML
> > table:
> >
> > <td><%=sessionvar1%><%=sessionvar2%></td>
> >
> > Compile and run, when I get to the 4th page it says that
sessionvar1 has
> not
> > been declared. Can I use session variables this way to display

the > > information?
> >
> >
>
>



Nov 17 '05 #4
I usually use the code behind but it doesn't make much difference I don't
suppose. I also use a delimiter which makes it easier to use the resultant
string later.

HTH
"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Justin, thanks for your reply.

I tried doing that way. The only problem doing it this way is this
information is coming from a series of check boxes on the first page. So
it
will vary the amount of information that will be displayed on the summary page. If I put all these label fields in that cell of the table, it will space it out and leave a huge gap. What I was looking to for was

something
that would allow the cell to conform to the amount of information that

will
be presented.

Thanks again.
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
> Michelle,
>
> No, that isn't the proper way to use them.
>
> I would put a label into the table and then when you get to the page set the
> text of the label = to the session variable.
>
> (e.g.
>
> Label1.Text = CType(Session("var1"), String)
>
> )
>
> Sincerely,
>
>
> --
> S. Justin Gengo, MCP
> Web Developer
>
> Free code library at:
> www.aboutfortunate.com
>
> "Out of chaos comes order."
> Nietzche
>
>
> "Michelle A." <me@me.com> wrote in message
> news:uF**************@TK2MSFTNGP12.phx.gbl...
> > I have a four page form. Pages 1-3 stores there information in a
session
> > variables. Page four is reached (a final review page) and then the > > information will be written to the SQL server.
> >
> > When I tried to enter some code in the HTML table by hand so I could get
> it
> > to show up in the right place. For example I use this code in the

HTML
> > table:
> >
> > <td><%=sessionvar1%><%=sessionvar2%></td>
> >
> > Compile and run, when I get to the 4th page it says that
sessionvar1 has
> not
> > been declared. Can I use session variables this way to display

the > > information?
> >
> >
>
>



Nov 17 '05 #5
Michelle,

I understand you don't know how many checkboxes values will need to be
displayed.

Do you know how to add labels to a control dynamically? I think this would
be the best solution.

Put a placeholder control in the table cell. Then dynamically create a label
for every check box that's checked and then add that label to the
placeholder.

'---Sample Code

If Session("Gifttoag") Then
Call AddLabel("College of Agriculture")
End If

If Session("Gifttobus") Then
Call AddLabel("College of Buisness ")
End If

If Session("Gifttodesign") Then
Call AddLabel("College of Design")
End If

'---This subroutine adds a label to the placeholder
Private Sub AddLabel(ByVal textToAdd As String)
Dim Label As New Label
Label.Text = textToAdd
Placeholder1.Controls.Add(Label)

Dim Literal As New LiteralControl
Literal.Text = "<br>"
Placeholder1.Controls.Add(Literal)
End Sub
Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Michelle A." <me@me.com> wrote in message
news:%2******************@tk2msftngp13.phx.gbl...
Let me add some code:

Here is the code behind page: (I know this might not be the most efficent
way )

An if statement checks what check boxes were checked and displays them to
the correct label in the table:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Session("Gifttoag") Then
Me.Label1.Text = "College of Agriculture"
Else
Me.Label1.Text = ""
End If
If Session("Gifttobus") Then
Me.Label2.Text = "College of Buisness "
Else
Me.Label2.Text = ""
End If
If Session("Gifttodesign") Then
Me.Label3.Text = "College of Design"
Else
Me.Label3.Text = ""
End If
If Session("Gifttoedu") Then
Me.Label4.Text = "College of Education"
Else
Me.Label4.Text = ""
End If
If Session("Gifttoengin") Then
Me.Label5.Text = "College of Engineering"
Else
Me.Label5.Text = ""
End If
If Session("Gifttofcs") Then
Me.Label6.Text = "College of Family and Consumer Sciences"
Else
Me.Label6.Text = ""
End If
If Session("Gifttolas") Then
Me.Label7.Text = "College of Liberal Arts and Sciences"
Else
Me.Label7.Text = ""
End If
If Session("Gifttovetmed") Then
Me.Label8.Text = "College of Veterinary Medicine"
Else
Me.Label8.Text = ""
End If
If Session("Gifttolibrary") Then
Me.Label9.Text = "University Library"
Else
Me.Label9.Text = ""
End If
If Session("Gifttomorrill") Then
Me.Label10().Text = "Morrill Hall Restoration Project"
Else
Me.Label10.Text = ""
End If
If Session("Gifttoarea") Then
Me.Label11().Text = "Area of Greatest Need"
Else
Me.Label11.Text = ""
End If

Me.Label12.Text = Session("Gifttoother")
Me.Label13.Text = Session("GiftAmount")
End Sub
Here is the HTML section where the information is displayed in the table.

<tr>
<td style="WIDTH: 268px; HEIGHT: 21px" align="left">Gift
Desgination(s):</td>
<td align="center" style="HEIGHT: 21px">

<asp:Label id="Label1" runat="server">Label</asp:Label>

<asp:label id="Label2" runat="server">Label</asp:label>
<asp:label id="Label3" runat="server">Label</asp:label>
<asp:label id="Label4" runat="server">Label</asp:label>
<asp:label id="Label5" runat="server">Label</asp:label>
<asp:label id="Label6" runat="server">Label</asp:label>
<asp:label id="Label7" runat="server">Label</asp:label>
<asp:label id="Label8" runat="server">Label</asp:label>
<asp:Label id="Label9" runat="server">Label</asp:Label>
<asp:Label id="Label10" runat="server">Label</asp:Label>
<asp:Label id="Label11" runat="server">Label</asp:Label>
<asp:Label id="Label12" runat="server">Label</asp:Label>
</td>
</tr>

"Michelle A." <me@me.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Would I add that in the HTML code or in the Code behind pages..?
"Jason (MFT1)" <us****@newsgroup.pls> wrote in message
news:eQ****************@TK2MSFTNGP09.phx.gbl...
concatenate
"Michelle A." <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Justin, thanks for your reply.
>
> I tried doing that way. The only problem doing it this way is this
> information is coming from a series of check boxes on the first page.
So
it
> will vary the amount of information that will be displayed on the

summary
> page. If I put all these label fields in that cell of the table, it

will
> space it out and leave a huge gap. What I was looking to for was
something
> that would allow the cell to conform to the amount of information
that will
> be presented.
>
> Thanks again.
>
>
> "S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
> news:uh**************@tk2msftngp13.phx.gbl...
> > Michelle,
> >
> > No, that isn't the proper way to use them.
> >
> > I would put a label into the table and then when you get to the page
set
> the
> > text of the label = to the session variable.
> >
> > (e.g.
> >
> > Label1.Text = CType(Session("var1"), String)
> >
> > )
> >
> > Sincerely,
> >
> >
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> >
> > Free code library at:
> > www.aboutfortunate.com
> >
> > "Out of chaos comes order."
> > Nietzche
> >
> >
> > "Michelle A." <me@me.com> wrote in message
> > news:uF**************@TK2MSFTNGP12.phx.gbl...
> > > I have a four page form. Pages 1-3 stores there information in

a > session
> > > variables. Page four is reached (a final review page) and then

the > > > information will be written to the SQL server.
> > >
> > > When I tried to enter some code in the HTML table by hand so I could get
> > it
> > > to show up in the right place. For example I use this code in the HTML
> > > table:
> > >
> > > <td><%=sessionvar1%><%=sessionvar2%></td>
> > >
> > > Compile and run, when I get to the 4th page it says that sessionvar1 has
> > not
> > > been declared. Can I use session variables this way to display the > > > information?
> > >
> > >
> >
> >
>
>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Google Mike | last post by:
Tell me if this can be done, and if I have a misconception here. I am writing an app that will be served up in an app farm, and therefore I need to move the session information to the client, not...
2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
1
by: Scott Wickham | last post by:
I'm having a problem saving session information on one form and retrieving it on a subsequent form...for only one out of a number of users. Actually, I'm not absolutely certain it's a session...
4
by: David | last post by:
Hi. I developed an ASP.NET application that users just started testing and found a huge problem with. In one part of the application I am creating an instance of the class and save information...
6
by: -D- | last post by:
I'm trying to accomplish the following. I'm trying to get the values for the table rows that are dynamically created to persist through a redirect. Referring URL:...
7
by: Mike | last post by:
Hi, I am developing an application with framesets (header, left navigation, and content). Each frameset loads an ".aspx" page, and in one of these pages, I store some information in the Session...
8
by: Steve Atkins | last post by:
I have an application where each user session opens and maintains a long-lived connection to the postgresql backend database. I need to keep a small amount of information (things like a unique...
2
by: asadikhan | last post by:
Hi, I have a table in my database called users which contains user information like their login id, password, first name, last name, phone, etc. Once I retreive this information, I'd like to...
3
by: RSH | last post by:
Hi, I have a situation where I have created an object that contains fields,properties and functions. After creating the object I attempted to assign it to a session variable so i could retrieve...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.