PDA

View Full Version : ScriptContainer indentations support



Ciaro
Jan 12, 2010, 1:03 PM
Hi,

ScriptManager seems to follow indentations, I was wondering if you could also add indentations support to ScriptContainer.

An Example:

CodeBehind:







// Add our custom javascript file


HtmlGenericControl js = new HtmlGenericControl("script");


js.Attributes["type"] = "text/javascript";


js.Attributes["src"] = "someScriptAddedinScriptContainer.js";


HtmlGenericControl title = new HtmlGenericControl("title");


title.InnerText = "TitleAddedInScriptContainer";





ScriptContainer scriptContainer = new ScriptContainer();


scriptContainer.Controls.Add(js);


scriptContainer.Controls.Add(title);





this.Page.Header.Controls.Add(scriptContainer);



Source:



<!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>
<!-- Coolite Toolkit for ASP.NET with ExtJS [Professional Edition]. Version 0.8.2.983. -->
<link rel="stylesheet" type="text/css" href="/extjs/resources/css/ext-all-embedded-css/coolite.axd?v=983" />
<style type="text/css">
.icon-folder{background-image:url(/icons/folder-png/coolite.axd) !important;}
</style>
<script type="text/javascript" src="someScriptAddedinScriptContainer.js"></script><title>TitleAddedInScriptContainer</title>
<script type="text/javascript" src="/extjs/adapter/ext/ext-base-js/coolite.axd?v=983"></script>
</PRE> <script type="text/javascript" src="/extjs/ext-all-js/coolite.axd?v=983"></script>
<script type="text/javascript" src="/coolite/coolite-core-js/coolite.axd?v=983"></script>
<script type="text/javascript" src="/extjs/locale/ext-lang-nl-js/coolite.axd?v=983"></script>
<script type="text/javascript">
//<![CDATA[
Ext.onReady(function(){...}
//]]>


</script>
<title>

</title></head>
<body>
</PRE>






Title seems to be added twice btw :(

geoffrey.mcgill
Jan 12, 2010, 7:03 PM
Title seems to be added twice btw :(


You probably have the <title> tag defined in the .aspx markup for the Page and then you're adding another with your HtmlGenericControl. We do not add the <title> tag.

geoffrey.mcgill
Jan 12, 2010, 7:06 PM
Hi Ciaro,

You can add a reference to a custom script by using the ScriptManagers .RegisterClientScriptInclude() Method.

Example



this.ScriptManager1.RegisterClientScriptInclude("custom", urlPath);


If you are adding custom controls to the Controls Collection, then its up to the developer to manage the tab/formatting of the rendered output.

Ciaro
Jan 13, 2010, 7:51 AM
geoffrey.mcgill (1/12/2010)

Title seems to be added twice btw :(


You probably have the <title> tag defined in the .aspx markup for the Page and then you're adding another with your HtmlGenericControl. We do not add the <title> tag.



Looks like the asp engine is adding those itself, I will look into that.

Ciaro
Jan 13, 2010, 8:04 AM
geoffrey.mcgill (1/12/2010)Hi Ciaro,


You can add a reference to a custom script by using the ScriptManagers .RegisterClientScriptInclude() Method.


Example



this.ScriptManager1.RegisterClientScriptInclude("custom", urlPath);


If you are adding custom controls to the Controls Collection, then its up to the developer to manage the tab/formatting of the rendered output.



Works like a charm :) Thanks mate.

Atm, I'm kinda missing the point of the ScriptContainer...

Ciaro
Jan 13, 2010, 9:05 AM
Ciaro (1/13/2010)
geoffrey.mcgill (1/12/2010)

Title seems to be added twice btw :(


You probably have the <title> tag defined in the .aspx markup for the Page and then you're adding another with your HtmlGenericControl. We do not add the <title> tag.



Looks like the asp engine is adding those itself, I will look into that.



http://haacked.com/archive/2009/04/03/tipjar-title-tags-and-master-pages.aspx

Problem is, the runat part is needed for coolite to run ^^

geoffrey.mcgill
Jan 13, 2010, 1:14 PM
The <ext:ScriptContainer> is used to control the exact placement of the required script and styles within the <head> or elsewhere.

The <ext:ScriptContainer> is not required.


In the upcoming v1.0 release, the <ext:ScriptContainer> has been renamed to <ext:ResourcePlaceholder>.

Ciaro
Jan 13, 2010, 3:09 PM
Thanks again, mate, really appriciate it.