How can I add an invisible form variable?

I have a manual table and I was wondering if there is anyway I can add an invisible form variable or text box. The reason I need it is so I can set it equal to the Title and set that to a session that I can reference throughout the rest of the application. This is the code I have. Any help would be appreciated.
Try
            dtr = Mycomm.ExecuteReader()
            If dtr.HasRows Then
                While dtr.Read()
 
                    If dtr("Title") = "" And dtr("Description") = "" Then
                    Else
                        success = "true"
                        vHtml = vHtml & "<TD align=""left""><FONT size=""1"" face=""Verdana""><a href='edit_election.aspx?id=" & dtr("id") & "'>(edit election)</a> "
                        vHtml = vHtml & "| <a href='delete.aspx?eid=" & dtr("id") & "' onClick=""return confirm('All associated items and responses will be deleted with this election. \n Are you sure you wish to delete this election?')"">(delete election)</a> "
                        vHtml = vHtml & "| <a href='item_list.aspx?id=" & dtr("id") & "'>(edit items)</a>"
                        vHtml = vHtml & "| <a href='response_list.aspx?id=" & dtr("id") & "'>(edit responses)</a></FONT></TD>"
                        vTitle = Replace(dtr("Title"), "''", "'")
                        'vBody = Replace(dtr("Body"), "''", "'")
                        vBody = Replace(dtr("Description"), vbCrLf, "<br>")
                        vStart = dtr("StartDate")
                        vEnd = dtr("EndDate")
                        vHtml = vHtml & "<tr>"
                        vHtml = vHtml & "<TD align=""left""><strong><FONT face=""Verdana"" size=""3"">" & vTitle & "</FONT></strong></TD>"
                        vHtml = vHtml & "</tr>"
                        vHtml = vHtml & "<tr colspan =""2"">"
                        vHtml = vHtml & "<TD  align=""left""><FONT face=""Verdana"" size=""1"">Dates Available: " & vStart & "</FONT>&nbsp;-&nbsp;<FONT face=""Verdana"" size=""1"">" & vEnd & "</FONT><br></TD> "
                        'vHtml = vHtml & "<TD align=""left""><FONT face=""Verdana"" size=""1""><asp:TextBox id=""txtTitle"" runat=""server"" Visible=""True"">" & vTitle & "</asp:TextBox></FONT><br></TD>"
                        vHtml = vHtml & "</tr>"
                        vHtml = vHtml & "<TD align=""left""><FONT face=""Verdana"" size=""2"">" & vBody & "</FONT><br><br></TD>"
                        vHtml = vHtml & "</tr>"
                        vHtml = vHtml & "<tr>"
                    End If
                End While
            Else
                success = "false"
            End If
            vHtml = vHtml & "<tr bgcolor=""#818EAD""><td colspan='11' align='Right'><FONT face=""Verdana"" size=""1"">&nbsp;</font></td></tr>"
            vHtml = vHtml & "<tr bgcolor=""#FFFFFF"">"
            vHtml = vHtml & "<th colspan=""11"" align=""right"">"
            vHtml = vHtml & "<HR>"
            vHtml = vHtml & "<FONT face=""Verdana"" size=""1"">&nbsp;</FONT>"
            vHtml = vHtml & "</th>"
            vHtml = vHtml & "</table>"
        Catch
        End Try

Open in new window

savache27Asked:
Who is Participating?
 
matthewrhoadesConnect With a Mentor Commented:
link1.href = "edit_election.aspx?id=" & dtr("id") & "&title=" & vTitle
<a id = "link1" runat = "server">(edit election)</a>


Something along those lines should do for you.

0
 
matthewrhoadesCommented:
Is it VB.NET or ASP.NET?  If it is VB.NET you are looking for a global variable I believe.  If that is the case you can add a variable using the keyword Friend.  I usually have a vb file as part of my project called modGlobals or something of the sort and it looks like this:  (See code below)

You can access those variables from any place in your project by calling myCaseId, or myUpdateConnStr, etc...


Module modGlobals
    Friend myCaseId As Int16 = Nothing
    Friend myUpdateConnStr As String = "F00"
    Friend myConnStr As String = Nothing
    Friend myUserId As Int16 = Nothing
    Friend myRecordId As Int32 = Nothing
    Friend myConnStatus As Int16 = 1
End Module

Open in new window

0
 
savache27Author Commented:
Well, I'm working in visual studio and building a manual  table, so I guess I'm really using asp.net. It's basically a datalist of elections and each election has a title. So when I go into the edit page I would like to keep up with the Title and add it to the edit page.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
matthewrhoadesCommented:
You can always add a text box and set the visible property to false.  Refer to the value of it using textboxname.text

You can also leave it visible and set the forecolor and backcolor of the text box to transparent.  

Or you can just store the information each time as SESSION["Title"]=vTitle so long as you have started a session at the beginning of your application.  
0
 
savache27Author Commented:
Actually, I don't think that will work for what I need because I would still have no way of telling which text box it was when they clicked on the edit since it's in a loop. Do you know anyway I could just add the title into this:

<a href='edit_election.aspx?id=" & dtr("id") & "'>(edit election)</a>

Seems like it would be something like this, but I'm just not sure how to add it in.

<a href='edit_election.aspx?id=" & dtr("id") & "' & "&title= " & vTitle & "  >(edit election)</a>
0
 
savache27Author Commented:
Thank you so much for your help!! That works perfectly!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.