473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Session-Object for more than 1 user control?

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
Nov 18 '05 #1
2 1276
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" <fs*******@informatik.uni-leipzig.de> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
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

Nov 18 '05 #2
Hello Angelo,

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

Ciao,
Frank
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rea | last post by:
Hi! I've searched high and low for this on the net but stil haven't found an answer. I'm trying to install both postnuke and xoops on a win2k server with php 4.3.3. and mysql installed. ...
2
by: | last post by:
I have a problem with session in my version of PHP I use WinXP (FAT32), Apache, latest PHP. In Linux, Apache, latest PHP instead it works fine! So, my program is: ----------------In Windows...
2
by: danielTI | last post by:
hi all, I am using Ubuntu hoary, kernel 2.6.10-5-386, apache 2, php 4 with th efollowing configuraton: session.save_handler = files session.save_path = /tmp session.use_cookies = 1...
3
by: PM | last post by:
I'm trying to make a kind of search history containing the 3 last searched words. So I'm using 3 Session Variables: Word1 / Word2 / Word3. In order to get this history working, I need to put the...
6
by: Al Jones | last post by:
This is a repost form the vbscript newgroup - if this isn't the appropriate group would you point me toward one that is. Basically, I seem to be losing session data part way though preparing an...
4
by: DC | last post by:
--when i set session.cache_limiter = private i get this Set-Cookie: PHPSESSID=61fdf683fef689d5371a1c01fd46e678; path=/; secure Expires: Thu, 19 Nov 1981 08:52:00 GMT No idea where it's pulling...
5
by: TRB_NV | last post by:
I'm losing information from my Session when I change pages or start the same page over again. I simplified the code so the example is really clear. The sample code that follows is supposed to...
7
by: aroraamit81 | last post by:
Well Guys, Here is a very strange trouble. When more than one users request tto same page at the same time then our session gets conflicted. Moreover I printed my SessionID, strangely but true I...
11
by: Bocah Sableng | last post by:
Hi, I'm new member of this group. I had added new virtual host at my intranet server. The new virtual host configuration on httpd.conf is similar with the old one. At the new virtual host, the...
5
by: lyealain | last post by:
<% If Session("username") = "" Then Response.Redirect("/CLS/Login.asp") End If Dim conn Dim connectstr Dim db_name, db_username, db_userpassword Dim db_server Dim res
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.