How can I add an invisible form variable?

Posted on 2008-11-13
Medium Priority
Last Modified: 2012-05-05
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.
            dtr = Mycomm.ExecuteReader()
            If dtr.HasRows Then
                While dtr.Read()
                    If dtr("Title") = "" And dtr("Description") = "" Then
                        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
                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>"
        End Try

Open in new window

Question by:savache27
  • 3
  • 3

Expert Comment

ID: 22954361
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


Author Comment

ID: 22954462
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.

Expert Comment

ID: 22954526
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.  
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 22955000
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>

Accepted Solution

matthewrhoades earned 2000 total points
ID: 22955107
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.


Author Closing Comment

ID: 31516548
Thank you so much for your help!! That works perfectly!!!

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 13 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question