ASP.NET 4: AJAX live binding
another cool feature with asp.net ajax v4 is live binding…
assuming we have a client based dataview you will have 4 cases of binding:
1- one time one way:
<h3>{{ Name }}</h3>
this means that the html element will be filled once with the javascript variable, if the variable changed later, the html element won’t change
2- live binding one way:
<h3>{binding Name}</h3>
same as above but the html element will be updated each time the variable change.. cool :), right ?
3-live binding two ways
<input type=”text” value=”{binding Name}”/>
same as above but also updated the source variable when the binded element (the textbox) value changes π
also if the same variable is bound to a textbox and another html element like this:
<h3>{{ binding Name }}</h3>
changing the textbox value will change the original variable and the h3 as well π
more here
ASP.NET 4: AJAX client templates
one big move for the ASP.NET ajax on version 4 is using client rendering instead of generating the the markup on the server:
the cool part is using native html elements as the data template:
<ul sys:attach=”dataview” class=”sys-template”
dataview:data=”{{ imagesArray }}”
>
<li>
<h3>{{ Name }}</h3>
<div>{{ Description }}</div>
</li>
</ul>
and to bind data to it:
<script type=”text/javascript”>// <![CDATA[
function pageLoad() {
var imagesArray = [];
var newImage = { Name: “Name”, Description: “Description” };
imagesArray.add(newImage);
}
// ]]></script>
and finally to automatically bind the json object to theΒ templated UI element, on the body
<body xmlns:sys=”javascript:Sys” sys:activate=”*”>
the sys:activate attribute will automatically activate all client based templates (btw the new client based templates called dataview in terms of asp.net 4 ) π
reference and more samples:
DNN Localization: Creating localized portals
Localizing DNN UI and controls is not that much Headache especially after using Global resources freely.. what about the content..
let’s assume we need to create a separate content hierarchy for each language just like this
the solution is simple..
- install the needed languages from admin β> languages
then at the bottom of the page click add new language
then choose the needed language, typically you will need the English and your native language, also make sure the enabled option is checked:
then from Host β> Portals click add new portal and create a new βParentβ portal as follow:
after that from admin β> site settings from advanced settings β> other settings set the default language to your native language:
now you cal repeat the previous steps for whatever languages you need, the good news is that these portals will automatically read the locale (culture and UICulture) according to its default language, so if you have created a localized UI/Control/Skin.. it will adapt automatically
cheers π
Ahmed
DNN Localization: strongly typed Global resources
By default DNN doesnβt support strongly typed global resources like the regular asp.net apps, also it has a slight difference on the local resources access.. here is a brief..
Local Resources
using the Localization class:
Localization.GetString("test.Text", LocalResourceFile);
notice the LocalResourceFile
variable.. it’s PortalModuleBase property
using the DNN:Label:
<dnn:Label ResourceKey=”test” runat=”server” id=”dnnlbl” /> will give the same result in a declarative way π
so what about Global Resources..
originally you can use:
Localization.GetString("txt.Text", Localization.GlobalResourceFile)
which will consume GlobalResources.resx under the App_GlobalResources directory, not good enough.. right ?
Strongly typed global resources:
resources DNN by default removed the .resx extension from the build provider tag:
<buildProviders>
<remove extension=”.resx” />
<remove extension=”.resources” />
</buildProviders>
and the solution is easy.. just go to http://dnnlocalization.codeplex.com/ and download the custom build provider and add it as follow:
<buildProviders>
<remove extension=”.resx” />
<remove extension=”.resources” />
<add extension=”.resx”
type=”BrandonHaynes.DotNetNukeResXBuildProvider.ResXBuildProvider,
BrandonHaynes.DotNetNukeResXBuildProvider” />
</buildProviders>
after that compile your website, and you will be able to access it like that:
Resources.content.strContent_Content
cheers π