ASP.NET 4: AJAX live binding

September 25, 2009 1 comment

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

Categories: ASPNET 4 Tags:

ASP.NET 4: AJAX client templates

September 25, 2009 1 comment

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:

http://www.asp.net/learn/whitepapers/aspnet40/

Categories: ASPNET 4 Tags:

DNN Localization: Creating localized portals

September 21, 2009 2 comments

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..

  1. install the needed languages from admin –> languages

image

then at the bottom of the page click add new language

image

then choose the needed language, typically you will need the English and your native language, also make sure the enabled option is checked:

image

then from Host –> Portals click add new portal and create a new β€œParent” portal as follow:

image

after that from admin –> site settings from advanced settings –> other settings set the default language to your native language:

image

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

Categories: DNN Tags:

DNN Localization: strongly typed Global resources

September 21, 2009 Leave a comment

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 πŸ™‚

Categories: DNN Tags: