Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Session-Object for more than 1 user control?

Reply
Thread Tools

Session-Object for more than 1 user control?

 
 
Frank Schumacher
Guest
Posts: n/a
 
      11-04-2004
Hi NG,

I have another problem with User controls. Thanks to your help I was
finaly able to create a Control, which is doing what I want it to do.

But now I want to add more than one User-Control to my WebForm.
Unfortunatly, my UserControl is using the Session-Variable to store some
values I need for each roundtrip. The problem is, that *each*
UserControl uses the same name for the Session-Variable.
I tried to add the instance-name of the Control to the Session-Variable
name to distinguish between the different UserControls, but I have no
clue, how to get this name.
The onClick-function is sending an object (sender) which I thought I
could use for. I tried to Cast it to System.Web.UI.UserControl, but this
has no name-property. Any ideas about this?

Oh well, and a second thing: I want to add the ucs dynamically. But how
can I then call the functions of my uc, for I have no variable at design
time.

Thanks in advance,
Frank
 
Reply With Quote
 
 
 
 
Angelos Karantzalis
Guest
Posts: n/a
 
      11-04-2004
Although your last name gives me bad Sunday morning memories ....

I think you can solve both your problems at once ...

Dynamically creating your controls and adding them to the page, requires at
least one variable:

MyControl objInstance = (MyControl )Activator.CreateInstance(blah-blah); //
or something similar

Now, if you add a public Id property to the MyControl class, your next line
could be:

objInstance.Id = controlIndex; // Where control index is some sort of unique
Id ...

.... add the control to a Hashtable - also a member variable of your class -
with the Id as the key ... and voila! ;] you now have a referece to the
instance of the control by Id, AND you have a unique identifier to use in
your session key.

Hope that pointed to the right direction ...
Angel
O:]


"Frank Schumacher" <(E-Mail Removed)-leipzig.de> wrote in message
news:(E-Mail Removed)...
> Hi NG,
>
> I have another problem with User controls. Thanks to your help I was
> finaly able to create a Control, which is doing what I want it to do.
>
> But now I want to add more than one User-Control to my WebForm.
> Unfortunatly, my UserControl is using the Session-Variable to store some
> values I need for each roundtrip. The problem is, that *each*
> UserControl uses the same name for the Session-Variable.
> I tried to add the instance-name of the Control to the Session-Variable
> name to distinguish between the different UserControls, but I have no
> clue, how to get this name.
> The onClick-function is sending an object (sender) which I thought I
> could use for. I tried to Cast it to System.Web.UI.UserControl, but this
> has no name-property. Any ideas about this?
>
> Oh well, and a second thing: I want to add the ucs dynamically. But how
> can I then call the functions of my uc, for I have no variable at design
> time.
>
> Thanks in advance,
> Frank



 
Reply With Quote
 
 
 
 
Frank Schumacher
Guest
Posts: n/a
 
      11-15-2004
Hello Angelo,

thanks for the head ups, they pointed me in the right direction.

Ciao,
Frank
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about LoginView control usage when a user in more than one user group Sinan Alkan ASP .Net 0 10-03-2008 01:30 PM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com Java 0 03-06-2008 08:11 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C++ 0 03-05-2008 08:41 AM
Like all great travelers, I have seen more than I remember andremember more than I have seen. shenrilaa@gmail.com C Programming 0 03-05-2008 03:26 AM
user should not logged in more than one using diffferent machins on website _thedebugger ASP .Net 2 08-23-2006 12:04 PM



Advertisments