Thursday, March 22, 2012

structure

Muhammad,

I assume you mean the Visual style of the pages?

There are a few ways this can be done, I personally use
WilsonMasterPages: -

http://authors.aspalliance.com/Paul...Articles/?id=14

Hth,
Phil Winstanley
Microsoft ASP.NET MVP
http://www.myservicescentral.comsorry didn't make myself clear, I want to use a data structure and assign
values to its members on different pages and offcourse want to retain all
values assigned on different pages.

"Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote in
message news:camdst$oni@.odak26.prod.google.com...
> Muhammad,
> I assume you mean the Visual style of the pages?
> There are a few ways this can be done, I personally use
> WilsonMasterPages: -
> http://authors.aspalliance.com/Paul...Articles/?id=14
> Hth,
> Phil Winstanley
> Microsoft ASP.NET MVP
> http://www.myservicescentral.com
Muhammad,

You could store this structure in the Application object, and update it
there. Although you may have threading issues, so use locking when
accessing it.

James

"Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
news:eFIQYgrUEHA.2388@.TK2MSFTNGP09.phx.gbl...
> sorry didn't make myself clear, I want to use a data structure and assign
> values to its members on different pages and offcourse want to retain all
> values assigned on different pages.
> "Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote in
> message news:camdst$oni@.odak26.prod.google.com...
> > Muhammad,
> > I assume you mean the Visual style of the pages?
> > There are a few ways this can be done, I personally use
> > WilsonMasterPages: -
> > http://authors.aspalliance.com/Paul...Articles/?id=14
> > Hth,
> > Phil Winstanley
> > Microsoft ASP.NET MVP
> > http://www.myservicescentral.com
Is it possible to definte a user defined stucture as application variable.
just of the sake of example

public struct student
{
int id;
string name;
float age;
string address1;
string address2;
}

How can I create an object of student type as an application variable?

"James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
news:e4qMukrUEHA.2520@.TK2MSFTNGP10.phx.gbl...
> Muhammad,
> You could store this structure in the Application object, and update it
> there. Although you may have threading issues, so use locking when
> accessing it.
> James
> "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> news:eFIQYgrUEHA.2388@.TK2MSFTNGP09.phx.gbl...
> > sorry didn't make myself clear, I want to use a data structure and
assign
> > values to its members on different pages and offcourse want to retain
all
> > values assigned on different pages.
> > "Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote
in
> > message news:camdst$oni@.odak26.prod.google.com...
> > > Muhammad,
> > > > I assume you mean the Visual style of the pages?
> > > > There are a few ways this can be done, I personally use
> > > WilsonMasterPages: -
> > > > http://authors.aspalliance.com/Paul...Articles/?id=14
> > > > Hth,
> > > Phil Winstanley
> > > Microsoft ASP.NET MVP
> > > http://www.myservicescentral.com
>
Define the struct as you have in a file within your project. In the
Application_Start event handler in the Global.asax file of your project,
enter the following code:

VB:
Dim oStudent As SomeNamespace.student
' Initialise
oStudent.ID = 0
oStudent.Age = 15
...

' Add the student to the application object
Application("Student") = oStudent

C#:
SomeNamespace.student oStudent;
// Initialise
oStudent.ID = 0;
oStudent.Age = 15;
...

// Add the student to the application object
Application["Student"] = oStudent;

The student struct will then be available to each page. To access it, use
the following code:

VB:
CType(Application("Student"), SomeNamespace.student) ...

C#:
(SomeNamespace.student)Application["Student"] ...

Hope this helps,

James

"Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
news:uTCmXtrUEHA.2972@.TK2MSFTNGP12.phx.gbl...
> Is it possible to definte a user defined stucture as application variable.
> just of the sake of example
> public struct student
> {
> int id;
> string name;
> float age;
> string address1;
> string address2;
> }
> How can I create an object of student type as an application variable?
> "James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
> news:e4qMukrUEHA.2520@.TK2MSFTNGP10.phx.gbl...
> > Muhammad,
> > You could store this structure in the Application object, and update it
> > there. Although you may have threading issues, so use locking when
> > accessing it.
> > James
> > "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> > news:eFIQYgrUEHA.2388@.TK2MSFTNGP09.phx.gbl...
> > > sorry didn't make myself clear, I want to use a data structure and
> assign
> > > values to its members on different pages and offcourse want to retain
> all
> > > values assigned on different pages.
> > > > "Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name> wrote
> in
> > > message news:camdst$oni@.odak26.prod.google.com...
> > > > Muhammad,
> > > > > > I assume you mean the Visual style of the pages?
> > > > > > There are a few ways this can be done, I personally use
> > > > WilsonMasterPages: -
> > > > > > http://authors.aspalliance.com/Paul...Articles/?id=14
> > > > > > Hth,
> > > > Phil Winstanley
> > > > Microsoft ASP.NET MVP
> > > > http://www.myservicescentral.com
> > > >
Excellent! that make 100% sense, will give it a go now thank you for help.

"James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
news:u2jIuzrUEHA.1036@.TK2MSFTNGP12.phx.gbl...
> Define the struct as you have in a file within your project. In the
> Application_Start event handler in the Global.asax file of your project,
> enter the following code:
> VB:
> Dim oStudent As SomeNamespace.student
> ' Initialise
> oStudent.ID = 0
> oStudent.Age = 15
> ...
> ' Add the student to the application object
> Application("Student") = oStudent
> C#:
> SomeNamespace.student oStudent;
> // Initialise
> oStudent.ID = 0;
> oStudent.Age = 15;
> ...
> // Add the student to the application object
> Application["Student"] = oStudent;
> The student struct will then be available to each page. To access it, use
> the following code:
> VB:
> CType(Application("Student"), SomeNamespace.student) ...
> C#:
> (SomeNamespace.student)Application["Student"] ...
> Hope this helps,
> James
> "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> news:uTCmXtrUEHA.2972@.TK2MSFTNGP12.phx.gbl...
> > Is it possible to definte a user defined stucture as application
variable.
> > just of the sake of example
> > public struct student
> > {
> > int id;
> > string name;
> > float age;
> > string address1;
> > string address2;
> > }
> > How can I create an object of student type as an application variable?
> > "James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
> > news:e4qMukrUEHA.2520@.TK2MSFTNGP10.phx.gbl...
> > > Muhammad,
> > > > You could store this structure in the Application object, and update
it
> > > there. Although you may have threading issues, so use locking when
> > > accessing it.
> > > > James
> > > > "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> > > news:eFIQYgrUEHA.2388@.TK2MSFTNGP09.phx.gbl...
> > > > sorry didn't make myself clear, I want to use a data structure and
> > assign
> > > > values to its members on different pages and offcourse want to
retain
> > all
> > > > values assigned on different pages.
> > > > > > "Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name>
wrote
> > in
> > > > message news:camdst$oni@.odak26.prod.google.com...
> > > > > Muhammad,
> > > > > > > > I assume you mean the Visual style of the pages?
> > > > > > > > There are a few ways this can be done, I personally use
> > > > > WilsonMasterPages: -
> > > > > > > > http://authors.aspalliance.com/Paul...Articles/?id=14
> > > > > > > > Hth,
> > > > > Phil Winstanley
> > > > > Microsoft ASP.NET MVP
> > > > > http://www.myservicescentral.com
> > > > > > > > >
there is no need to use the application collection. you can just declare a
static version of your struct.

class myGlobal
{
static public struct student = initStudent();
}

you will need to sync access to members

-- bruce (sqlwork.com)

"James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
news:u2jIuzrUEHA.1036@.TK2MSFTNGP12.phx.gbl...
> Define the struct as you have in a file within your project. In the
> Application_Start event handler in the Global.asax file of your project,
> enter the following code:
> VB:
> Dim oStudent As SomeNamespace.student
> ' Initialise
> oStudent.ID = 0
> oStudent.Age = 15
> ...
> ' Add the student to the application object
> Application("Student") = oStudent
> C#:
> SomeNamespace.student oStudent;
> // Initialise
> oStudent.ID = 0;
> oStudent.Age = 15;
> ...
> // Add the student to the application object
> Application["Student"] = oStudent;
> The student struct will then be available to each page. To access it, use
> the following code:
> VB:
> CType(Application("Student"), SomeNamespace.student) ...
> C#:
> (SomeNamespace.student)Application["Student"] ...
> Hope this helps,
> James
> "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> news:uTCmXtrUEHA.2972@.TK2MSFTNGP12.phx.gbl...
> > Is it possible to definte a user defined stucture as application
variable.
> > just of the sake of example
> > public struct student
> > {
> > int id;
> > string name;
> > float age;
> > string address1;
> > string address2;
> > }
> > How can I create an object of student type as an application variable?
> > "James Doran" <jamied1@.NO_SPAMbreathe.com> wrote in message
> > news:e4qMukrUEHA.2520@.TK2MSFTNGP10.phx.gbl...
> > > Muhammad,
> > > > You could store this structure in the Application object, and update
it
> > > there. Although you may have threading issues, so use locking when
> > > accessing it.
> > > > James
> > > > "Muhammad Sheikh" <Muhammad.Sheikh@.4mat.com> wrote in message
> > > news:eFIQYgrUEHA.2388@.TK2MSFTNGP09.phx.gbl...
> > > > sorry didn't make myself clear, I want to use a data structure and
> > assign
> > > > values to its members on different pages and offcourse want to
retain
> > all
> > > > values assigned on different pages.
> > > > > > "Phil Winstanley [Microsoft MVP ASP.NET]" <phil@.winstanley.name>
wrote
> > in
> > > > message news:camdst$oni@.odak26.prod.google.com...
> > > > > Muhammad,
> > > > > > > > I assume you mean the Visual style of the pages?
> > > > > > > > There are a few ways this can be done, I personally use
> > > > > WilsonMasterPages: -
> > > > > > > > http://authors.aspalliance.com/Paul...Articles/?id=14
> > > > > > > > Hth,
> > > > > Phil Winstanley
> > > > > Microsoft ASP.NET MVP
> > > > > http://www.myservicescentral.com
> > > > > > > > >

0 comments:

Post a Comment