Arrays (?) in Kentico Transformation - transformation

{Kentico 10}
I want to display a URL based on an authenticated user's membership type/level. I have a custom table (MemberURL) that keys the MembershipGUID from the CMS_Membership table to the record in the MemberURL table.
I have a DataSource webpart pulling data from the custom table. -- works
I have a Universal Viewer With Custom Query that returns the data -- works
The transformation on this viewer webpart:
<%# CurrentUser.FullName %> -- <%# CurrentUser.UserName %><br/>
<%# CurrentUser.Memberships.Count %>><br>
<%# Eval("MembershipGUID") %>
<%# Eval("Description") %>
<%# Eval("WebTixsURL") %>
<%# Eval("Children_Max") %>
<%# Eval("Guest_Max") %>
<%# Eval("Adult_Max") %>
---returns all the data expected ==> the first two rows from the CurrentUser object and the last six from the custom table.
I am trying to find a way to look at the Current Users' membership type (level in our parlance) and compare the GUID of that level/type with the MembershipGUID from the custom table to determine which URL should be displayed.
I can't seem to return any of the CurrentUser's Memberships data in the transformations I am trying to build.

I would recommend creating a custom transformation method. And in the code of the method, using the current user context you can get the details about the user and execute the logic you want and return desired URL as the result.

Related

In ASP.NET WebForms, what is the difference between <%:, <%=, and <%#?

This question is proving hard to google, so if there is a duplicate question & answer or definitive reference, please share.
<% %> An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class. http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx
<%= %> most useful for displaying single pieces of information. http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx
<%# %> Data Binding Expression Syntax. http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx
<%$ %> ASP.NET Expression. http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx
<%# %> Directive Syntax. http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx
<%-- --%> Server-Side Comments. http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx
<%: %> Like <%= %> But HtmlEncodes the output (new with Asp.Net 4). http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx
It is actually described pretty well in msdn.
Check out following link:
http://msdn.microsoft.com/en-us/library/fy30at8h(v=vs.71).aspx

Globalize3 module translation for database

I got an issue with Globalize3, i have build a module to add translations in Admin for Preferences User
I display each translation by her ID and her locale. But i don't understand why the locale is not define when i want to display the page.
The gist for better show : https://gist.github.com/266562670cd8dab28548#gistcomment-43681
Thanks for your help
Fixed.
If you have a look at the params you are getting in the update action for the perference topic translation (just raise params[:preference_topic_translation]). You'll notice you probably have preference_topic_option_translation coming through as one of the attributes which doesn't exist on the model.
You need to update line #12 in the form:
<%= f.fields_for preference_topic_option_translation do |translate_form| %>
It should read:
<%= f.fields_for :preference_topic_option_translations, preference_topic_option_translation do |translate_form| %>

In ASP.NET MVC what are the differences between "<%=", "<%:" "<%#"

I've tried to perform a search on the above query but probably due to the angle brackets, I didn't find anything on the matter.
Could anyone please explain what the differences are between <%=, <%: <%#?
I seem to recall that <%# is preferred over <%= but I am not sure why.
The following article describes them pretty well.
<%=: Rendering Code Syntax
<%: %>: HTML encoded renedring (same usage as <%=)
<%# %>: Data Binding Syntax - works with server side controls in classic WebForms applications, inapplicable in MVC
<%= xxx %> Inserts the text in xxx into the page at that location. (more info)
<%: xxx %> Same as above except it html encodes the text for your convenience - (Except if xxx is an HtmlString which indicates it is already encoded)
<%# xxx %> Same as the first one too except xxx is only evaluated when DataBind() is called on the form (not really applicable in MVC) (more info)
Martin

Problem with using Html.RenderPartial() in MVC 3

I have a user control which accepts an 'Id' from the page where it is embedded. I used the following code to display " <% Html.RenderPartial("ViewUserControl3", Model.Guid); %>" to display the user control with specific id on the page. Any one please help me How to get that Guid in my usercontrol page and display the user control on the page where it is called.
Thanks in Advance
Your ViewUserControl3 should be strongly typed to Guid and then simply use this model:
<%# Control
Language="C#"
Inherits="System.Web.Mvc.ViewUserControl<System.Guid>" %>
<div><%= Model %></div>

How to assign a master to an existant webform?

My friend I are collaborating on a project, he's going to create the Master Page and I'll create the forms.
How can I assign a master page to my existent .aspx form?
I believe the only thing you need to do is have MasterPageFile in your page declaration, like so:
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master"
CodeFile="ContentPage.aspx.cs" Inherits="ContentPages_ContentPage" %>
And, of course, make sure you use the <asp:Content> tags to design your page.
<asp:Content ID="mainContent" runat=server ContentPlaceholderID=ContentPlaceholder1>

Resources