Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

weird placeholder + session behaviour ! please hel


  • Please log in to reply

#1
xjpmauricio

xjpmauricio

    New Member

  • Member
  • Pip
  • 1 posts
I'm Having a weird thing with this placeholder, i'm trying to add controls that are stored in a session object: Session["controls"]

THE PROBLEM: in the following piece of code, only the literal controls are shown on the page but the button (web control) doesn´t show! it only shows if i put it before the literal controls but then the literal disapear!!! weird!!! please help!!!



// Create an HtmlButton control.
HtmlButton button = new HtmlButton();
button.InnerHtml = "Click Me! I'm a button!";

PlaceHolder ph1 = new PlaceHolder();

ph1.Controls.Add(new LiteralControl(@"<div id=""Layer1"" style=""position:absolute; width:200px; height:115px; z-index:1; left: 385px; top: 268px"">")); // LITERAL CONTROL
ph1.Controls.Add(button); // WEB CONTROL
ph1.Controls.Add(new LiteralControl("<br>my div - literal</div>")); // LITERAL CONTROL

Session["controls"] = ph1;//ADDS ALL CONTROLS TO SESSION VAR


try // ITERATES THROUGH SESSION CONTROLS
{
PlaceHolder ph2 = ((PlaceHolder)(Session["controls"]));
for (int i = 0; i <= ph2.Controls.Count - 1; i++)
{
PlaceHolder1.Controls.Add(ph2.Controls[i]);
}
}
catch(Exception ex){}



TNX
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP