|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Simple Pulbic VariableI'm new. I have an aspx page and I want to declare a public variable
"GroupID" at the top of the page and be able to change the value in different parts of that particular page. Bascially, how do you creat a public variable for one page only? Thanks! If you want to use it within the page, declare it within the class
definition like Private GroupID as Integer Regards, Trevor Benedict MCSD Show quoteHide quote "pvong" <phillip*at*yahoo*dot*com> wrote in message news:%23%23S16hUMIHA.1188@TK2MSFTNGP04.phx.gbl... > I'm new. I have an aspx page and I want to declare a public variable > "GroupID" at the top of the page and be able to change the value in > different parts of that particular page. Bascially, how do you creat a > public variable for one page only? > Thanks! > Perfect! Thanks!
Show quoteHide quote "Trevor Benedict" <TrevorN***@yahoo.com> wrote in message news:OWtxi5UMIHA.2208@TK2MSFTNGP06.phx.gbl... > If you want to use it within the page, declare it within the class > definition > like > > Private GroupID as Integer > > Regards, > > Trevor Benedict > MCSD > > "pvong" <phillip*at*yahoo*dot*com> wrote in message > news:%23%23S16hUMIHA.1188@TK2MSFTNGP04.phx.gbl... >> I'm new. I have an aspx page and I want to declare a public variable >> "GroupID" at the top of the page and be able to change the value in >> different parts of that particular page. Bascially, how do you creat a >> public variable for one page only? >> Thanks! >> > > Is this by design....
When I have an onclick of a control, it assigns the public variable a value. When I click on another control, the value is gone from the public variable? Am I not sticking the public variable in the right place. This is where I have it in my code behind... Imports System.Data, System.Data.SqlClient Partial Class Client_ClientMtgNote Inherits System.Web.UI.Page Public groupid As Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Show quoteHide quote "Trevor Benedict" <TrevorN***@yahoo.com> wrote in message news:OWtxi5UMIHA.2208@TK2MSFTNGP06.phx.gbl... > If you want to use it within the page, declare it within the class > definition > like > > Private GroupID as Integer > > Regards, > > Trevor Benedict > MCSD > > "pvong" <phillip*at*yahoo*dot*com> wrote in message > news:%23%23S16hUMIHA.1188@TK2MSFTNGP04.phx.gbl... >> I'm new. I have an aspx page and I want to declare a public variable >> "GroupID" at the top of the page and be able to change the value in >> different parts of that particular page. Bascially, how do you creat a >> public variable for one page only? >> Thanks! >> > > pvong,
A webpage is not persisitent, in other words, all information in the class will be destroyed at the moment that you send the page. To make things global for a page of a certain user there are 3 methods, for which in my idea the session.item is in most cases the most effective to use. Cor "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message Session isn't for the one page only though, as the OP wants. Granted, he news:A6239591-41E0-43C9-A796-CD4F7C3F1C14@microsoft.com... > pvong, > > A webpage is not persisitent, in other words, all information in the class > will be destroyed at the moment that you send the page. > > To make things global for a page of a certain user there are 3 methods, > for which in my idea the session.item is in most cases the most effective > to use. > > Cor can get at it in the single page, but it is scoped for the entire session for all pages under a single site. OP: To store a value for the current user for the current page, you'd want to use something like the ViewState. ViewState("MyPropertyName") = MyValue HTH, Mythran Mytrhan,
The way you describe it can in my idea bemisunderstood. A session is for all pages, however not for all users. As long as you don't use an item on another page, then it is for one page. You describe in my idea in a way the status of a static class and the cache from ASP.NET. To a user belongs the session and the vieuwstate as you wrote. The session does not for nothing use the cookie. The problem with a viewstate is that it is transported over the InterNet and can make the transaction long. Cor Show quoteHide quote "Mythran" <kip_pot***@hotmail.com> schreef in bericht news:7DA0D4ED-86EF-4EB8-A2F3-8B741416B603@microsoft.com... > > > "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message > news:A6239591-41E0-43C9-A796-CD4F7C3F1C14@microsoft.com... >> pvong, >> >> A webpage is not persisitent, in other words, all information in the >> class will be destroyed at the moment that you send the page. >> >> To make things global for a page of a certain user there are 3 methods, >> for which in my idea the session.item is in most cases the most effective >> to use. >> >> Cor > > Session isn't for the one page only though, as the OP wants. Granted, he > can get at it in the single page, but it is scoped for the entire session > for all pages under a single site. > > OP: > To store a value for the current user for the current page, you'd want to > use something like the ViewState. > > ViewState("MyPropertyName") = MyValue > > HTH, > Mythran > > Thanks you both. I will use a Session and clear it on page load not
postback. Phil Show quoteHide quote "Cor Ligthert[MVP]" <notmyfirstn***@planet.nl> wrote in message news:A6239591-41E0-43C9-A796-CD4F7C3F1C14@microsoft.com... > pvong, > > A webpage is not persisitent, in other words, all information in the class > will be destroyed at the moment that you send the page. > > To make things global for a page of a certain user there are 3 methods, > for which in my idea the session.item is in most cases the most effective > to use. > > Cor
sort two arrays as one?
Copying files with progress bar How to stop disabled text boxes being greyed out VB2008 changes? Exclude code of my application Vb.Net/SQL slowdown Call HTML control in code behind (ASP.net 2.0) Kill explorer process and disable it restart automatically Problem Using VB.net Class Library DLL in VBScript [VB2008] How to replace lines in a textfile? |
|||||||||||||||||||||||