Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Getting data from the header control

  Asked By: Grant    Date: Nov 30    Category: Asp.net    Views: 5414

i have index.aspx page which contain header control.
this control is the header for all pages.
in the header.ascx file im creating an object wich expose me very important
parameters about the client who log in:
i need this information for all my pages.
my q is , how can those properties can be recognized in the index.aspx which
host the header control.
One important thing is that im dont want to use sessions.
i thought to expose the userObj.properties as the header control properties but
it's not working.
is it better to leave the control idea and just include the header section
instead of control?



8 Answers Found

Answer #1    Answered By: Riley-jack Johnson     Answered On: Nov 30

No. Web User Controls should do the job just ok. Maybe you are accessing those
properties at wrong time. Try saving those prop values inside ViewState like:

public string userName
get { return (string)ViewState["accessUserName"]; }
set { ViewState["accessUserName"] = value; }

But you probably access those values in the same postback, so you must ensure
that properties  are set before they are accessed. Try debuging and see what
exactly is going on.

Answer #2    Answered By: Kawthar Malik     Answered On: Nov 30

it's still make me problems.
here is the header.ascx.cs:

private void Page_Load(object sender, System.EventArgs e)

public string name
return userObj.name;

now in the index.aspx.cs im referencing to the control:

protected netTools.header adminTop;

and then trying to print the name property

and the result is empty string...

if im changing the name property return value to some hard code
return "bla"
it's working  well...

Answer #3    Answered By: Anthony Smith     Answered On: Nov 30

Rename your property to userName or something else, because your Control already
has a propery Name... I think...

Answer #4    Answered By: Edna West     Answered On: Nov 30

i already changed it...
still dont give me the value.It's empty

Answer #5    Answered By: Guilherme Silva     Answered On: Nov 30

Have you debugged it and stepped into...

Answer #6    Answered By: James Evans     Answered On: Nov 30

your code suggests you have your Properties defined in your page
load ?? that's wrong .. define them in your variables declaration.

don't know if this will make a difference

private void Page_Load(object sender, System.EventArgs e)

public string name
return userObj.name;

Also I have done a little project that will help you, if not confuse you,
involving asxc, customcontrols etc ... and at no point does it fail to get
to the control's variable.
It should alos give you some food for thought.

Give it five mins to allow me to zip it and upload it.

Answer #7    Answered By: Clarence Nichols     Answered On: Nov 30


just unzip it to your Inetpub/www folder and create a virtual dir for it.

Answer #8    Answered By: Geena Ma.     Answered On: Nov 30

of course i defined the properties  outside the page_load

public string name
> {
> get
> {
> return userObj.name;
> }
> }

anyway it's not working...
thanks a ton about the zip - i will look at it

Didn't find what you were looking for? Find more on Getting data from the header control Or get search suggestion and latest updates.