Need to make control equal to control

  • Thread starter Thread starter Ron Vecchi
  • Start date Start date
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,
 
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.
 
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?
 
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.
 
Back
Top