Need to make control equal to control

R

Ron Vecchi

I have a situation where I need to make PlaceHolderA equal to
PlaceHolderB
and keep the contents of PlaceHolderB after PlaceHolderA has been destroyed.

is this possible seeing that it is a referenced copy of PlaceHolderA?


Thanks,
 
J

Jacob Yang [MSFT]

Hi Ron,

I apologize for it if there is any misunderstanding.

As I understand, what you want is getting the content of the placeholder.
Please refer to the following code snippet.

...
private void Button2_Click(object sender, System.EventArgs e)
{
foreach(Control b in PlaceHolder1.Controls)
{
if(b.GetType().ToString() =="System.Web.UI.WebControls.TextBox")
{
PlaceHolder2.Controls.Add ( b );
((TextBox)(b)).Attributes.Add("style",@"Z-INDEX: 103; LEFT: 116px;
POSITION: absolute; TOP: 128px");
}
}
}
...

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
R

Ron Vecchi

What im tring to do is have a clone of a placeholder.
It would be great if there was a WebControl.Clone() method.

My situation is that I have a custom control that has two child PlaceHolder
Controls.
In most situations both placeholders will need to have the identical child
control structure.

Sorry for the bad questioning but what I should have asked is that is there
a WebControl.Clone method or something similar?
 
J

Jacob Yang [MSFT]

Hi Ron,

Based on my research and experience, there is not such a WebControl.Clone()
method for the PlaceHolder. I think that we can try to use the following
code:

...
private void Button2_Click(object sender, System.EventArgs e)
{

PlaceHolder2 = PlaceHolder1;
PlaceHolder1.Dispose();
foreach(Control b in PlaceHolder2.Controls)
{
if(b.GetType().ToString() =="System.Web.UI.WebControls.TextBox")
{
Response.Write("b.GetType().ToString()");
PlaceHolder2.Controls.Add ( b );
((TextBox)(b)).Attributes.Add("style",@"Z-INDEX: 103; LEFT: 116px;
POSITION: absolute; TOP: 128px");
}

}

}
...

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top