How to assign a master to an existant webform? - webforms

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>

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.

struts2 ajax redirect

i develop a app that is built with struts2+tiles+dojo (for the ajax part), and i have the following demand: At every 2 seconds i have to check a table from the DB, if certain conditions are met, i have to redirect the user to a special page.
The way that i solved this problem was creating a struts2 actions which`s check the table and render as a response something like :
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<script>
window.location= '<s:property value="url"/>';
</script>
</body>
</html>
and this page is accesed via a ajax call like:
<sx:div href="%{ajaxUrl}"
updateFreq="1200"
cssStyle="float:right"
id="live"
loadingText="Loading..."
executeScripts="true"
parseContent="false">
</sx:div>
and this is how i accomplish the redirect.
I`m sure that there has to be an more elegant and optimized solution.
Any ideeas ?
Use the struts2-json-plugin on the action which is the target of ajaxUrl. I don't use the sx tags, I just use JS (with jQuery, the normal library not using any struts2 plugin). Any ways use JS to asynchronously call your action every 2 seconds with JS (or framework of choice) and you will get back the url as a json string, and you will then redirect to that new url if the string is not empty (or you could return back many variables perhaps, perhaps containing some of the conditions found in the DB and showing them on the page and redirect according to those status variables).

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>

View rendering problem

In my application I have two Master pages and they are used in various different cases. Say one master view just renders the top half of the page and another master view that renders the top half plus a navigation bar to the side. We pass around data to these Master pages using view models
Now in my controller my index action refers to the MasterPage with the navigation bar and a details tab that does not need the navigation bar. But there is a problem now whenever I try to render the Details page my site crashes at the Site.MasterWithNavigation although it is noway involved with my details view. i have no clue how it lands up there.
On attaching the debugger and checking where the pae is crashing it showed me it is crashing at the Site.MasterWithNavigation and on checking the call stack there was just one entry which took me to my other Site.Master and showed the exception at a random partial view rendering line. I thought just for the heck of it let me comment out that piece of line and again saw the crash occurring now at a different line where I render an HTML input element.
Any idea why the hell I am seeing this? Note we have other pages that use the second master page but for some reason they are all in a different controller called WhateeverDetailsController. Do you think there is a problem when we use two different master pages across two different actions within the same controller.
I am not sure why you are using multile master pages together but I use one master page only, and expose relevant tags to all pages such as:
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Title
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContentHolder" runat="server">
<%= Html.Script("jquery-1.4.4.min.js")%>
<%= Html.Script("jquery-ui-1.8.7.min.js")%>
<%= Html.Script("MicrosoftAjax.js")%>
<%= Html.Script("MicrosoftMvcAjax.js")%>
<%= Html.Script("MicrosoftMvcValidation.js")%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MenuContent" runat="server">
<% Html.RenderPartial("IManagerLinks"); %>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent" runat="server">
<div id="leftContent50">
<h4>add a new comment</h4>
<% Html.RenderPartial("AddCommentUC", Model.AddComment); %>
</div>
<div id="rightContent50">
something else here
</div>
<br style="clear: both;" />
</asp:Content>
You could very easily do the same for the top part of your page, side part and title and use css to style everything up.

Resources