eddyperu
asked on
how can I add a DIV using the server side(C#)?
HI experts:
I am using C#
I need to add this section inside this <DIV id="ContingetFirstBox">... .//add here </DIV>
Section that need to be added to my page
<div style="float:left;padding- right:60px ;">// this is a session text "myName "</div>
<div style="float:left;padding- right:60px ;"><img src="images/primary.png" alt="s" /></div>
<div style="float:left;">100%</ div>
<div style="clear: both;"></div>
In my C# I have this:
protected void Page_Load(object sender, EventArgs e)
{
String myName = Session["ValueContingent"] .ToString( );
// This is where I need to add that section
}
Thanks
I am using C#
I need to add this section inside this <DIV id="ContingetFirstBox">...
Section that need to be added to my page
<div style="float:left;padding-
<div style="float:left;padding-
<div style="float:left;">100%</
<div style="clear: both;"></div>
In my C# I have this:
protected void Page_Load(object sender, EventArgs e)
{
String myName = Session["ValueContingent"]
// This is where I need to add that section
}
Thanks
So :
protected void Page_Load(object sender, EventArgs e)
{
String myName = Session["ValueContingent"].ToString();
ContingetFirstBox.InnerHtml = Server.HtmlEncode(myName);
}
ASKER
Sorry I think it wasn't that clear:
I need to add all this section:
<div style="float:left;padding- right:60px ;">//Strin g myName = Session["ValueContingent"] .ToString( );</div>
<div style="float:left;padding- right:60px ;"><img src="images/primary.png" alt="s" /></div>
<div style="float:left;">100%</ div>
<div style="clear: both;"></div>
Inside this div :
<DIV id="ContingetFirstBox" runat="server"> ....</DIV>
Thanks
I need to add all this section:
<div style="float:left;padding-
<div style="float:left;padding-
<div style="float:left;">100%</
<div style="clear: both;"></div>
Inside this div :
<DIV id="ContingetFirstBox" runat="server"> ....</DIV>
Thanks
Perhaps an easier solution is to use a panel (uses div) or placeholder (no div) control which should just be a drag and drop. Then just drop a label or literal control into the panel control. Modify the text property.
Try :
protected void Page_Load(object sender, EventArgs e)
{
String myName = Session["ValueContingent"].ToString();
String ihtml = "<div style=\"float:left;padding-right:60px;\">" + myName;
ihtml += "</div><div style=\"float:left;padding-right:60px;\"><img src=\"images/primary.png\" alt=\"s\" />";
ihtml += "</div><div style=\"float:left;\">100%</div><div style=\"clear: both;\"></div>";
ContingetFirstBox.InnerHtml = ihtml;
}
Tested, it work :
Page :
Page :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<DIV id="ContingetFirstBox" runat="server"></DIV>
</div>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points!
Use : ContingetFirstBox.InnerHtm
Check example here : http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlcontainercontrol.innerhtml.aspx