473,396 Members | 2,109 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,396 software developers and data experts.

Confused with Controls

Hi everybody, I'm hoping you can help me understand why this doesn't
work, and perhaps someone can suggest a way for me to solve my problem.
Essentially, I'm trying to add a row with a single cell twice in a
table. Both cells are identical and therefore I don't want to
duplicate everything in the code. My function determines at runtime if
there should be two identical cells or just a single cell. Here is
some sample code, which only displays the contents of a single cell.

protected void Page_Load(object sender, EventArgs e)
{
Table atable = new Table();
TableRow arow = new TableRow();
TableCell acell = new TableCell();
HyperLink alink = new HyperLink();

alink.NavigateUrl = "aaaaaaaaaa";
alink.Text = "aaaaaaaaaaaaaaaaaaaaaaa";

acell.Controls.Add(alink);
arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

Page.Controls.Add(atable);
}

Now from what I gather, when I do a object.Controls.Add(object) it is
infact moving the object to the new control. So how do I go about
putting the contents of a cell into two different rows in a table? My
exact application is that I want my users to have the option to have a
combination of [menu] - {Gallery Picture} - [menu], with the choices of
displaying the menu on Top, Bottom or Top&Bottom at the same time.

Any help would be appreciated,
Thanks,
Nicholas

Sep 2 '06 #1
3 1253
Encoad,

You are never moving an object, as long as it exist it stays for ever on the
same place.
What you are doing is playing with references to it.
You can set hundred times a reference to it. To explain with some code

\\\
Object myObject = new Object(); ///whatever class
Object myOtherObject = myObject; ///this is a reference to the same object
ArrayList myArray = new ArrayList();
myArray.Add(myOtherObject);
///therefore the same object is twice referenced in the arraylist
myArray.Add(myObject);
///

I hope this help,

Cor

<en****@gmail.comschreef in bericht
news:11*********************@p79g2000cwp.googlegro ups.com...
Hi everybody, I'm hoping you can help me understand why this doesn't
work, and perhaps someone can suggest a way for me to solve my problem.
Essentially, I'm trying to add a row with a single cell twice in a
table. Both cells are identical and therefore I don't want to
duplicate everything in the code. My function determines at runtime if
there should be two identical cells or just a single cell. Here is
some sample code, which only displays the contents of a single cell.

protected void Page_Load(object sender, EventArgs e)
{
Table atable = new Table();
TableRow arow = new TableRow();
TableCell acell = new TableCell();
HyperLink alink = new HyperLink();

alink.NavigateUrl = "aaaaaaaaaa";
alink.Text = "aaaaaaaaaaaaaaaaaaaaaaa";

acell.Controls.Add(alink);
arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

Page.Controls.Add(atable);
}

Now from what I gather, when I do a object.Controls.Add(object) it is
infact moving the object to the new control. So how do I go about
putting the contents of a cell into two different rows in a table? My
exact application is that I want my users to have the option to have a
combination of [menu] - {Gallery Picture} - [menu], with the choices of
displaying the menu on Top, Bottom or Top&Bottom at the same time.

Any help would be appreciated,
Thanks,
Nicholas

Sep 2 '06 #2
Hi Cor, thanks for the reply.

So why is it that my code does not work? Why am I unable to add the
link into two different cells and those cells into two different rows
into the same table? Compile the code and you'll see.

Thanks again,
Nicholas

Cor Ligthert [MVP] wrote:
Encoad,

You are never moving an object, as long as it exist it stays for ever on the
same place.
What you are doing is playing with references to it.
You can set hundred times a reference to it. To explain with some code

\\\
Object myObject = new Object(); ///whatever class
Object myOtherObject = myObject; ///this is a reference to the same object
ArrayList myArray = new ArrayList();
myArray.Add(myOtherObject);
///therefore the same object is twice referenced in the arraylist
myArray.Add(myObject);
///

I hope this help,

Cor

<en****@gmail.comschreef in bericht
news:11*********************@p79g2000cwp.googlegro ups.com...
Hi everybody, I'm hoping you can help me understand why this doesn't
work, and perhaps someone can suggest a way for me to solve my problem.
Essentially, I'm trying to add a row with a single cell twice in a
table. Both cells are identical and therefore I don't want to
duplicate everything in the code. My function determines at runtime if
there should be two identical cells or just a single cell. Here is
some sample code, which only displays the contents of a single cell.

protected void Page_Load(object sender, EventArgs e)
{
Table atable = new Table();
TableRow arow = new TableRow();
TableCell acell = new TableCell();
HyperLink alink = new HyperLink();

alink.NavigateUrl = "aaaaaaaaaa";
alink.Text = "aaaaaaaaaaaaaaaaaaaaaaa";

acell.Controls.Add(alink);
arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

Page.Controls.Add(atable);
}

Now from what I gather, when I do a object.Controls.Add(object) it is
infact moving the object to the new control. So how do I go about
putting the contents of a cell into two different rows in a table? My
exact application is that I want my users to have the option to have a
combination of [menu] - {Gallery Picture} - [menu], with the choices of
displaying the menu on Top, Bottom or Top&Bottom at the same time.

Any help would be appreciated,
Thanks,
Nicholas
Sep 2 '06 #3
EnCoad,

It is in my idea strange, because in my idea this is something the same.

\\\
object Whatever = new object();
Whatever = "Whatever";
TableCell acel1 = new TableCell();
TableCell acel2 = new TableCell();
acel1.Text = Whatever.ToString();
acel2.Text = Whatever.ToString();
TableRow arow = new TableRow();
arow.Cells.Add(acel1);
Table atable = new Table();
atable.Controls.Add(arow);
arow = new TableRow();
arow.Cells.Add(acel2);
atable.Controls.Add(arow);
Page.Controls.Add(atable);
//
And this goes very nice while it is two times referencing the same object
Whatever.

As well I was not able to debug it because the quickview did give
information about cells which are not in that class.

Sorry

Cor
<en****@gmail.comschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...
Hi Cor, thanks for the reply.

So why is it that my code does not work? Why am I unable to add the
link into two different cells and those cells into two different rows
into the same table? Compile the code and you'll see.

Thanks again,
Nicholas

Cor Ligthert [MVP] wrote:
>Encoad,

You are never moving an object, as long as it exist it stays for ever on
the
same place.
What you are doing is playing with references to it.
You can set hundred times a reference to it. To explain with some code

\\\
Object myObject = new Object(); ///whatever class
Object myOtherObject = myObject; ///this is a reference to the same
object
ArrayList myArray = new ArrayList();
myArray.Add(myOtherObject);
///therefore the same object is twice referenced in the arraylist
myArray.Add(myObject);
///

I hope this help,

Cor

<en****@gmail.comschreef in bericht
news:11*********************@p79g2000cwp.googlegr oups.com...
Hi everybody, I'm hoping you can help me understand why this doesn't
work, and perhaps someone can suggest a way for me to solve my problem.
Essentially, I'm trying to add a row with a single cell twice in a
table. Both cells are identical and therefore I don't want to
duplicate everything in the code. My function determines at runtime if
there should be two identical cells or just a single cell. Here is
some sample code, which only displays the contents of a single cell.

protected void Page_Load(object sender, EventArgs e)
{
Table atable = new Table();
TableRow arow = new TableRow();
TableCell acell = new TableCell();
HyperLink alink = new HyperLink();

alink.NavigateUrl = "aaaaaaaaaa";
alink.Text = "aaaaaaaaaaaaaaaaaaaaaaa";

acell.Controls.Add(alink);
arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

arow = new TableRow();
arow.Controls.Add(acell);
atable.Controls.Add(arow);

Page.Controls.Add(atable);
}

Now from what I gather, when I do a object.Controls.Add(object) it is
infact moving the object to the new control. So how do I go about
putting the contents of a cell into two different rows in a table? My
exact application is that I want my users to have the option to have a
combination of [menu] - {Gallery Picture} - [menu], with the choices of
displaying the menu on Top, Bottom or Top&Bottom at the same time.

Any help would be appreciated,
Thanks,
Nicholas

Sep 2 '06 #4

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

Similar topics

2
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put...
8
by: Rachel Suddeth | last post by:
I'm trying to use reflection to create an object at runtime where the type is given by a string. I thought we should be able to do that, but so far it's not working. I'm trying to work on...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
9
by: JohnSmith | last post by:
I suspect this is easy, but I have been stumped for a day trying to solve this.. I want to be able to have an unlimited number of aspx pages that all use the code in one class file. I want code...
6
by: Louise | last post by:
I use Visual Basic .NET Framework 1.1, Visual Studio. I have a Web page (aspx) referencing a control (ascx) that has a placeholder that is assigned one of 2 child controls through buttons. The...
2
by: Alan Silver | last post by:
Hello, I have code like the following... foreach (Control ctl in Page.Controls) { if (ctl.ID.StartsWith("X_")) { // do stuff } }
7
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be...
4
by: Tarun Mistry | last post by:
Hi everyone. I want to perform some login checking in one of my webforms to decide on what content to show, is this possible? Should i be doing this differently (btw im a new .net programmer moving...
7
by: AndrewMBaldwin | last post by:
I have a grid control (inherits from Placeholder) that has a few buttons on it. On this grid there is a filter form, which allows the user to filter/search the table for specific information. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.