OneOfBristolsBest
New Member
Hi<BR><BR>How can I make the HTML generated by a custom server control (*.ascx and *.ascx.cs files) output its generated content as relative to the placement of the control ?<BR><BR>Currently my control outputs a table correctly but in the source it is located at the very top instead of within the body tags ?<BR><BR>This I think occurs due to the runat=server attribute but cannot figure out a way to correct this issue.<BR><BR>Thew resultant output of the code listed below can be seen at: <BR>http://johncogan.brinkster.net/index2.aspx<BR><BR>Any pointers are appreciated.<BR>(Code follows)<BR>TIA<BR>John<BR><BR>My ASPX file is as follows:<BR>----------------------------------------------------------<BR><%@Page debug="true" %><BR><%@ Register TagPrefix="menu" tagname="menuOut" src=http://aspmessageboard.com/archive/index.php/"menu.ascx"%> <BR><html><BR><head><BR><title>Untitled Document</title><BR><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><BR><link rel="stylesheet" href="css/port.css" type="text/css"><BR><script language="Javascript1.2" src="menu.js"></script><BR></head><BR><BR><body bgcolor="#FFFFFF" text="#000000"><BR>Test<br /><BR><menu:menuOut id="menu" runat="server" xmlSource="menu.xml" xslSource="menu.xslt" /><br /><BR>Test 2<BR></body><BR></html><BR><BR>menu.ASCX Code as follows:<BR>---------------------------------------------------------<BR><%@ Control Language="c#" %><BR><%@ Import Namespace="System.Xml" %> <BR><%@ Import Namespace="System.Xml.Xsl" %> <BR><%@ Import Namespace="System.Xml.XPath" %> <BR><script runat="server" language="c#"><BR> public string xmlSource, xslSource;<BR> <BR> void Page_Load(){<BR> XmlDocument docXml = new XmlDocument();<BR> docXml.Load(Server.MapPath(xmlSource));<BR> XslTransform docXsl = new XslTransform();<BR> docXsl.Load(Server.MapPath(xslSource));<BR> <BR> docXsl.Transform(docXml,null,Response.Output);<BR> }<BR></script>I'm not entirely sure if I'm understanding the question, but this is what I've been doing in similar situations. First I'll add a <asp:label id="myHTML" runat="server"/> in the spot I want to render the HTML. Then within my script I'll just set myHTML.text = <outputted html from your control><BR><BR>])ry