Thank you Cerebrus. Yestarday night I used Page.ClientScript.RegisterStartupScript method and worked fine for me.
My problem was that I'm using this component to chart. http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html The same as Google use it on Google Finance. Excelent, and I recommend it! And the best way to set values from your database is via javascript. So I created a script with all the data.setValue in a string in the Page_Load. Well, I discovered that was not functioning 'cause the <div> used to the chart control didn't has width e height set... :P On Sat, Nov 15, 2008 at 9:46 AM, Cerebrus <[EMAIL PROTECTED]> wrote: > > HI Alberto, > > Welcome to the Group ! > > You have not shown us the Javascript that you are trying to include. > Therefore, I do not understand the pressing requirement to include the > Javascript in the Head tag itself. Usually, script sections within the > Head tag are used to list functions that can be called via code in the > Body section. Since those functions are not executed automatically > during the Page load, the script can be inserted manually into the > ASPX page's head section at design time. > > If the invocation of those script functions needs to be > programmatically determined, then that can be done via the > Page.ClientScript.RegisterStartupScript method. > > > On Nov 14, 10:41 pm, "Alberto Chvaicer" <[EMAIL PROTECTED]> wrote: > > Hello people, > > > > I'm new in this group, but I already have a few years on development in > > C#.Net and VB.Net > > > > I need to create the a javascript in the <head> tag. > > > > So I tryed some ways that didn't worked. > > > > 1. I created an aspx that return the javascript code with > > Response.Output.Write and put it in the src attribute. > > > > <script type="text/javascript" src="GetJSChart.aspx?IdAcao=<%= > > Request.QueryString["IdAcao"] %>"></script> > > > > But the page GetJSChart.aspx was never called. > > > > 2. I tryed changing the page GetJSChart.aspx to HTTPHandler. > > > > <script type="text/javascript" src="GetJSHandler.ashx?IdAcao=<%= > > Request.QueryString["IdAcao"] %>"></script> > > > > The handler was never called too. > > > > 3. Then a generated the code in the Page_Load and inserted in the <head> > > > > HtmlGenericControl > > script = new HtmlGenericControl("script"); > > script.Attributes.Add("type", "text/javascript"); > > script.InnerText = jsCode; > > this.Header.Controls.Add(script); > > > > But every " (quote) in the code was replaced to " and the js didn't > > work. > > > > I tryed to use HttpUtility methods to fix it, but the code still been > > generated with " > > > > 4. So I use the generated code in the Page_Load and tryed to insert by > > another way. > > > > Page.ClientScript.RegisterClientScriptBlock(this.Header.GetType(), "sct", > > jsCode, true); > > > > This fixed the HTML Encoding. > > But the code was inserted in the <body> tag. And I need in the <head>. > > > > I know that this e-mail is a little confuse. > > But if someone could help me to fix any of the solutions that I tryed to > > create or have a better one, I'll apreciate it. > > > > Thanks, > > Alberto >
