Problem with using Html.RenderPartial() in MVC 3 - asp.net-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>

Related

Phoenix different title per page with root module

This question is similar to (but not an exact duplicate of) Phoenix Framework - page titles per route.
Ideally, i want to create titles like in the described question, but I am using a root layout since my project uses Phoenix LiveView. The HTML skeleton including the head and title HTML tag are part of the root template (root.html.eex). The app template extends on that from my understanding. I implemented the code from the above question
<title>
<%= if Kernel.function_exported?(#view_module, :title, 2) do %>
<%= #view_module.title(Phoenix.Controller.action_name(#conn), assigns) %> - StHub
<% else %>
StHub
<% end %>
</title>
and created a title function inside of my specific page view
defmodule StHubWeb.WowsView do
use StHubWeb, :view
def title(_action, _assigns) do
"Dashboard"
end
end
but the else branch of the code is triggered. Upon further inspection, I think that the issue is with using a root template, because the #view_module while rendering the root template is StHubWeb.LayoutView, and only inside of the LayoutView/app.html.eex template, the #view_module is my actual view (StHubWeb.WowsView).
I am not sure how to solve this other than removing the root template, but then my LiveView will have to contain the entire HTML skeleton all the time.
Maybe there is a way for me to define a title function in my LayoutView that will grab the title from StHubWeb.WowsView, but I am not sure how to do that.
Thanks for the help!

Arrays (?) in Kentico 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.

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

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