Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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