Professional Web Applications Themes

Writing Session Variable Information To a Table - ASP.NET General

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?...

  1. #1

    Default 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?


    Michelle Guest

  2. #2

    Default Re: Writing Session Variable Information To a Table

    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" <com> wrote in message
    news:phx.gbl... 
    the [/ref]
    session 
    > it 
    > not 
    >
    >[/ref]


    Michelle Guest

  3. #3

    Default Re: Writing Session Variable Information To a Table

    concatenate


    "Michelle A." <com> wrote in message
    news:%phx.gbl... 
    it 
    something 
    will 
    > the [/ref]
    > session [/ref][/ref]
    get [/ref][/ref]
    HTML [/ref][/ref]
    has 
    > >
    > >[/ref]
    >
    >[/ref]


    Jason Guest

  4. #4

    Default Re: Writing Session Variable Information To a Table

    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." <com> wrote in message
    news:%23vXeVM%phx.gbl... [/ref]
    > So [/ref]
    > summary [/ref]
    > will 
    > > something 
    > > will [/ref]
    > set [/ref][/ref]
    the [/ref][/ref]
    could 
    > > HTML [/ref][/ref]
    sessionvar1 [/ref][/ref]
    the 
    > >
    > >[/ref]
    >
    >[/ref]


    Michelle Guest

  5. #5

    Default Re: Writing Session Variable Information To a Table

    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." <com> wrote in message
    news:%23vXeVM%phx.gbl... [/ref]
    > So [/ref]
    > summary [/ref]
    > will 
    > > something 
    > > will [/ref]
    > set [/ref][/ref]
    the [/ref][/ref]
    could 
    > > HTML [/ref][/ref]
    sessionvar1 [/ref][/ref]
    the 
    > >
    > >[/ref]
    >
    >[/ref]


    Jason Guest

  6. #6

    Default Re: Writing Session Variable Information To a Table

    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." <com> wrote in message
    news:%23P0xJR%phx.gbl... [/ref][/ref]
    page. 
    > > summary 
    > > will [/ref][/ref]
    that [/ref][/ref]
    page [/ref][/ref]
    a [/ref]
    > the [/ref]
    > could [/ref][/ref]
    the [/ref]
    > sessionvar1 [/ref]
    > the 
    > >
    > >[/ref]
    >
    >[/ref]


    S. Guest

Similar Threads

  1. Writing an array into a session variable
    By Udo Schmitt in forum ASP Components
    Replies: 0
    Last Post: February 16th, 04:52 PM
  2. Writing a session variable when inserting a record
    By AIH2005 in forum Dreamweaver AppDev
    Replies: 4
    Last Post: June 3rd, 12:50 PM
  3. Replies: 7
    Last Post: July 29th, 10:35 AM
  4. Replies: 0
    Last Post: July 25th, 09:52 AM
  5. Password Table with Session Variable
    By Frank Py in forum ASP Database
    Replies: 2
    Last Post: July 15th, 10:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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