My application use a masterpage which the ContentPlaceHolder align is center. But whenever, I use Response.Write() function to write something on screen, the whole page just changed to align left. I’m thinking, jquery ajax function could let me write html into some part of the page without destroy align. But I’d like to know if there is better solution. Any idea?
Here’s the code in code page:
DirectoryInfo di = new DirectoryInfo("e:/asdf");
FileInfo[] rgFiles = di.GetFiles("*.*");
if (rgFiles != null)
{
sb.Append("<span class='SubTitle'>Your attachments list:</span>");
foreach (FileInfo fi in rgFiles)
{
sb.AppendFormat("<br><a href='e:\\asdf\\" + fi.Name + "'>"
+ fi.Name + "</a>");
}
}
Response.Write("<span style='position:absolute;top:200px;left:200px'>"
+ sb + "</span>");
Avoid using Response.Write() to add content to the page, rather, you should add content to a server control.
In the web form:
In the code behind:
This will keep your content within the CSS definitions you set for that server control.