I believe I've done something similar to this before, where I wanted to push
extra controls onto the end of a form. I did this by referencing the form in
my codebehind and then using the Form.Controls.Add(Control) method to add
whichever controls I wanted to create programatically during the PreRender
event.
The PreRender event is effectively the last event to fire before the ASPX
page saves the controls to viewstate, it is the last event available to be
overloaded prior to the page rendering out--it even fires after the Event
Handlers.
Try putting a runat="server" attribute in your body tag (ie: <body
id="bdyPage" runat="server"> of your aspx markup, and then referencing it as
an HtmlGenericControl in your codebehind: protected
System.Web.UI.HtmlControls.HtmlGenericControl bdyPage). Then overload the
ASPX page's PreRender event and output your StringBuilder/JavaScript to the
page at that time. You can expose this through a public method or property
in your custom menu control.
Hope it works/helps.
--
Cheers,
Jonathan
"Hawk" wrote:
I have a custom menu control that I am creating using C#. I am rendering
HTML from a StringBuilder in my control to add the needed JavaScript to the
HTML output. I need to have the JavaScript output from the stringbuilder
placed at the bottom of my <BODY> section, after the top navigation menu
dropdown dataset output. Currently the JavaScript is output to the top of
the <BODY> section of my HTML output from the control.
How can I accomplish this?
Thanks,
Hawk