This is a migrated thread and some comments may be shown as answers.
Script Registrar Config
8 Answers 280 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Luke Ryan
Top achievements
Rank 1
Luke Ryan asked on 19 Feb 2010, 03:03 AM

Hi,

Just a question regarding the Script Registrar and it's config.
Is there a way i can declare the script groups in code, yet set the groups Combined / Compress values in config?
eg:

site.master
  Html.Telerik().ScriptRegistrar().Scripts(scripts => scripts
                                                        .AddGroup("NewGroup", group =>
                                                            group
                                                            .Add("~/Scripts/newscript.js"));

web.config
 <!--Web Assests-->
  <telerik>
    <webAssets>
      <scripts>
        <add name="NewGroup" combined="true" compress="true" enabled="true">
        </add>
      </scripts>
    </webAssets>
  </telerik>

Thanks for ya help.

8 Answers, 1 is accepted

Sort by
0
Kazi Manzur Rashid
Telerik team
answered on 19 Feb 2010, 02:55 PM
Hi Luke Ryan,

Yes you can create SharedWebAsset and Import it in your page.

For example in global.asax application start:

SharedWebAssets.StyleSheets(group =>
                                group.AddGroup("appStyles",
                                                  styles => styles.Add("site.css")
                                                                  .Add("openid.css")
                                                                  .Add("form.css")
                                                                  .Add("telerik.common.css")
                                                                  .Add("telerik.forest.css"))
                           );

SharedWebAssets.Scripts(group =>
                            group.AddGroup("publicScripts",
                                            scripts => scripts.Add("jquery.validate.js")
                                                              .Add("jquery.form.js")
                                                              .Add("jquery.color.js")
                                                              .Add("jquery.watermark.js")
                                                              .Add("jquery.openid.js")
                                                              .Add("createShortUrl.js"))
                        );


Now in the page:

    

    

Sincerely yours,
Kazi Manzur Rashid
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Luke Ryan
Top achievements
Rank 1
answered on 20 Feb 2010, 02:12 AM
Thanks for ya reply,
Give the code you just gave, how would i then go about configuring the script combining / compression via the web.config for those groups.
eg.
-- Global.asax
SharedWebAssets.StyleSheets(group =>                                
group.AddGroup("appStyles",styles => styles.Add("site.css")        
                                            .Add("openid.css")    
                                            .Add("form.css")   
                                            .Add("telerik.common.css")      
                                            .Add("telerik.forest.css"))         
                  );
-- Web.config
<!--Web Assests-->
  <telerik>
    <webAssets>
      <scripts>
        <add name="appStyles" combined="true" compress="true" enabled="true">
        </add>
      </scripts>
    </webAssets>
  </telerik>

0
Kazi Manzur Rashid
Telerik team
answered on 25 Feb 2010, 08:05 AM
Hi Luke Ryan,

It should look something like the following:

<telerik>
  <webAssets>
    <styleSheets>
        <add name="appStyles" combined="true" compress="true">
            <items>
                <add source="site.css" />
                <add source="openid.css" />
                <add source="form.css" />
                <add source="Telerik.Common.css" />
                <add source="Telerik.forest.css" />
           </items>
        </add>
    </styleSheets>
    <scripts>
        <add name="appScripts" combined="true" compress="true">
            <items>
               <add source="jquery.validate.js"/>
              <add source="jquery.form.js"/>
              <add source="jquery.color.js"/>
           </items>
        </add>
    </scripts>
  </webAssets>
</telerik>

Greetings,
Kazi Manzur Rashid
the Telerik team


Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Luke Ryan
Top achievements
Rank 1
answered on 25 Feb 2010, 08:27 PM
Thanks,
I don't think you are understanding me, I'm aware of how to do it when adding new groups like you described above. However what i'm wanting is to do Declare the groups in CODE and configure their script combining in CONFIG.
So if i had in my
GLOBAL.ASAX
SharedWebAssets.StyleSheets(group =>  
group.AddGroup("appStyles",styles => styles.Add("site.css")        
                                            .Add("openid.css")    
                                            .Add("form.css")   
                                            .Add("telerik.common.css")      
                                            .Add("telerik.forest.css"))         
                  );
I want to configure that groups combining and compression in
WEB.CONFIG
<telerik>
    <webAssets>
      <scripts>
        <GET NAME="appStyles" combined="true" compress="true" enabled="true">
        </add>
      </scripts>
    </webAssets>
  </telerik>

This way i can turn on and off the combining without having their values set in CODE. Does this make sense?

Thanks again.

0
Kazi Manzur Rashid
Telerik team
answered on 26 Feb 2010, 09:43 AM
Hello Luke Ryan,

Sorry I could not get your point.

You can declare the groups in the web.config like the following:

<telerik>
  <webAssets>
    <styleSheets>
        <add name="appStyles" combined="true" compress="true"/>
    </styleSheets>
    <scripts>
        <add name="appScripts" combined="true" compress="true"/>
    </scripts>
  </webAssets>
</telerik>

and then add the items with the following (check that I am using GetGroup instead of AddGroup):

SharedWebAssets.StyleSheets(group =>
                                group.GetGroup("appStyles",
                                                  styles => styles.Add("site.css")
                                                                  .Add("openid.css")
                                                                  .Add("form.css")
                                                                  .Add("telerik.common.css")
                                                                  .Add("telerik.forest.css"))
                           );

SharedWebAssets.Scripts(group =>
                            group.GetGroup("appScripts",
                                            scripts => scripts.Add("jquery.validate.js")
                                                              .Add("jquery.form.js")
                                                              .Add("jquery.color.js")
                                                              .Add("jquery.watermark.js")
                                                              .Add("jquery.openid.js")
                        );

Greetings,
Kazi Manzur Rashid
the Telerik team


Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Kenneth Jamieson
Top achievements
Rank 1
answered on 02 Mar 2010, 05:45 PM
Can someone point me at the documentation for the syntax needed to declare this stuff in web.config and global.asax? In fact, anythign resembling real documentation for the web assets registrars would really help!
0
Luke Ryan
Top achievements
Rank 1
answered on 02 Mar 2010, 09:39 PM
That works thanks for that :)
Tags
General Discussions
Asked by
Luke Ryan
Top achievements
Rank 1
Answers by
Kazi Manzur Rashid
Telerik team
Luke Ryan
Top achievements
Rank 1
Kenneth Jamieson
Top achievements
Rank 1
Share this question
or