Added scripts do not appear in HTML when visiting site - c#

DNN Version: 04.09.05 (yes, I know it's old. This is one of the oldest sites maintained by the company I work for)
I'm not entirely sure what code to include here, since it seems almost irrelevant. Here's my issue:
I have added a mobile redirect script to a the skin.ascx for a DNN site:
<%# Control language="vb" CodeBehind="~/admin/Skins/skin.vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Skins.Skin" %>
<%# Register TagPrefix="dnn" TagName="LOGO" Src="~/Admin/Skins/Logo.ascx" %> <%# Register TagPrefix="dnn" TagName="SOLPARTMENU" Src="~/Admin/Skins/SolPartMenu.ascx" %>
<%# Register TagPrefix="dnn" TagName="USER" Src="~/Admin/Skins/User.ascx" %> <%# Register TagPrefix="dnn" TagName="LOGIN" Src="~/Admin/Skins/Login.ascx" %>
<%# Register TagPrefix="dnn" TagName="CURRENTDATE" Src="~/Admin/Skins/CurrentDate.ascx" %>
<%# Register TagPrefix="dnn" TagName="LANGUAGE" Src="~/Admin/Skins/Language.ascx" %>
<%# Register TagPrefix="dnn" TagName="SEARCH" Src="~/Admin/Skins/Search.ascx" %>
<%# Register TagPrefix="dnn" TagName="BREADCRUMB" Src="~/Admin/Skins/BreadCrumb.ascx" %>
<%# Register TagPrefix="dnn" TagName="LINKS" Src="~/Admin/Skins/Links.ascx" %> <%# Register TagPrefix="dnn" TagName="COPYRIGHT" Src="~/Admin/Skins/Copyright.ascx" %>
<%# Register TagPrefix="dnn" TagName="TERMS" Src="~/Admin/Skins/Terms.ascx" %> <%# Register TagPrefix="dnn" TagName="PRIVACY" Src="~/Admin/Skins/Privacy.ascx" %>
<%# Register TagPrefix="dnn" TagName="HELP" Src="~/Admin/Skins/Help.ascx" %>
<%# Register TagPrefix="dnn" TagName="HOUSEMENU" Src="~/DesktopModules/HouseMenuSkinObject/HouseMenuSkinObject.ascx" %>
<!-- Mobile Redirect -->
<script src="/Portals/_default/skins/*********/scripts/redirection-mobile.js"></script>
<script>
SA.redirection_mobile();
</script>
<!-- / Mobile Redirect -->
<!-- www.DotNetNukeSkin.com, www.DNNSource.com, www.DNNBlast.com -->
but despite my efforts to clear the DNN cache and even restart the application, this never appears when visiting the site.
Here's what I see where that script should be:
<script src="/WebResource.axd?d=Vfg8rdbqjJxftEOai7TpkVMgS5M3EpWnLJOIYxski_LUgp8dX_IpQo23OtpIMPbl9BRn7Gvd5xGcDwPU0&t=635359717876031270" type="text/javascript"></script>
<script src="/js/dnncore.js" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=EHk-FrMHceUyqcY0-Ou7uoHZdqiXevkiBXGM4IwtB9QaoQazyRuYSotYRd4XIARQzPydSQ5xOERE5RYgV-OvRozQDW8PaDmPnWhQI1UYydn9DyMcGUSN9-XtqJ5WOQA1G57ez5pQ9bzPvHpo6Wyh8yUGgFY1&t=ffffffffa37d832a" type="text/javascript"></script>
<script src="/ScriptResource.axd?d=aMtM2AA2yI3ghP5Pe-NcoK-AYskpYVGguYXvrwDo1MUnUBn18bqEEGw8_GdcQ79Ecs7d5GcFroKs5--e-ZmUr3jRRMfTGboqIz4N8yPYJIojGGy6AnIDkQR4Hp1W3z4jIWzDpSXifOa6inrF-rghB-sjnyjG9wsURK0oHw2&t=ffffffffa37d832a" type="text/javascript"></script>
<!-- www.DotNetNukeSkin.com, www.DNNSource.com, www.DNNBlast.com -->
Any ideas?

You would typically need to verify that ANYTHING you put into the HTML shows up. I imagine that you will find that it won't.
If that's the case, you'll need to track down which Skin is actually in use, and make sure you're changing the right one.
The skin could be in the path you mention above
/portals/_default/skins/skinname/
but it could also be pulling from
/portals/#/skins/skinname where # is the ID of the Portal.
So basically, start by verifying you're in the right place, then make changes from there. The HTML you're putting in shouldn't cause any problems with DNN itself, so that leads me to believe you're simply not looking in the right place..

Related

Finding What Populates Content Placeholder on ASP.NET Site

I have very little experience with ASP or .NET but have a need to make some content and style edits to one of such sites. The problem is that I am having a hard time finding the section which I need to edit.
In the main file called default.aspx, there is code like this:
<%# Page Title="" Language="VB" MasterPageFile="~/Company_New_NoMenus.master" CodeFile="Default.aspx.vb" Inherits="_Default" AutoEventWireup="false" %>
<%# Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
content here
The content which needs to be edited is located inside the ContentPlaceHolderID="HeadContent". I cannot find where it is populated. I tried searching the directory of the site to no avail.
If you use Windows Server, IIS and ASP, I would love some ideas about where I could look for it. Could it be set in the environment or be done in some other strange way? How would you look for it?
Any help is appreciated!

How to express directives as C# so they can be conditional

This markup supports code that is not rendered in the mobile version of the page on which I'm working.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%# Register Src="Cart.ascx" TagName="Cart" TagPrefix="uc1" %>
<%# Register Src="Search.ascx" TagName="Search" TagPrefix="uc5" %>
<%# Register Src="Credits.ascx" TagName="Credits" TagPrefix="uc6" %>
<%# Register Src="Menu.ascx" TagName="Menu" TagPrefix="uc3" %>
<%# Register Src="taskspanel.ascx" TagName="TasksPanel" TagPrefix="uc6" %>
Unsurprisingly a lot of unnecessary scripts are loaded. This is bad.
If there is markup to make these registrations conditional please refer me to documentation. Otherwise, my current thought is to use explicit code equivalent to the markup, and make it conditional that way.
I've discovered ScriptManager from this rather old resource but the above markup doesn't reference js files explicitly so I don't know how to map between the two. Can anyone advise?
Attempting to use superjos' response below I modified my page to reference Page.Mobile, a Boolean property conveniently already in place:
<%# Page Language="C#" AutoEventWireup="false" EnableViewStateMac="false" CodeBehind="Forms.aspx.cs" Inherits="ASSAOHS.forms" %>
<%# if (!Mobile) { %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%# Register Src="Cart.ascx" TagName="Cart" TagPrefix="uc1" %>
<%# Register Src="Search.ascx" TagName="Search" TagPrefix="uc5" %>
<%# Register Src="Credits.ascx" TagName="Credits" TagPrefix="uc6" %>
<%# Register Src="Menu.ascx" TagName="Menu" TagPrefix="uc3" %>
<%# Register Src="taskspanel.ascx" TagName="TasksPanel" TagPrefix="uc6" %>
<%# } %>
but this produces Parser Error Message: The server block is not well formed.
Writing it like this
<%# Page Language="C#" AutoEventWireup="false" EnableViewStateMac="false" CodeBehind="Forms.aspx.cs" Inherits="ASSAOHS.forms" %>
#if (!Mobile) {
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<%# Register Src="Cart.ascx" TagName="Cart" TagPrefix="uc1" %>
...
}
doesn't produce an error but isn't processed; the if statement and braces are simply passed through and rendered as text at the browser.
Which leaves me back with option two, map the directives to explicit code using ScriptManager to register stuff. Any takers?
Thanks to Pedro for trying to help but that reference doesn't help with how to express those control directives as code.
It looks like I may need to use option three, which redirect to another page that doesn't contain the directives.
Have you tried with this SO answer? Basically by having some value conditionally taking a true/false value in C# code:
public bool IsDebugBuild
{
get
{
#if DEBUG
return true;
#else
return false;
#endif
}
}
and then using only that bit from code as an #if condition in Razor, keeping all the rest still in Razor?
Another answer is saying the same as well.
Disclaimer: I haven't tried this, and I've not been playing with <%# Register> directives for a looooong time.

Create a partial class with inheritance in aspx without recompiling

I am really new to C#/VB as a web coding language so apologies early if this is rudimentary
I have a vendor .NET solution i need to add an .aspx page to, which I've managed to do, but there are missing HTML items that are placed by backend .vb file code (we have the uncompiled code as well as the site code)
so for example, Report.aspx
uncompiled
<%# Page Language="vb" AutoEventWireup="false" Inherits="jobber.VU.Report"
CodeFile="Report.aspx.vb" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
compiled
<%# page language="vb" autoeventwireup="false" inherits="jobber.VU.Report,
App_Web_report.aspx.cdcab7d2" enableEventValidation="false" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
the VB backend
Namespace jobber.VU
Partial Class Report
Inherits ActionBase
End Class
End Namespace
How do I replicate that in just an ASPX page?
I tried this
<%# page language="vb" AutoEventWireup="false" Debug="true" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
<%# Import Namespace="jobber.VU.ActionBase" %>
<VU:metatags id="headers1" format="none" runat="server"></VU:metatags>
and VU.Controls comes back fine, but the ActionBase class is not executing
I also attempted a <script runat=server, but it never took off the ground
You can have multiple pages inherit from the same page. So if you want to duplicate the functionality of the 'jobber.VU.Report page', just add a new page and inherit from it.

user control not rendering content of ascx

i thought this was a simple issue until i started searching for answers and realised it's so simple i'm the only one who has it
my user control isnt displaying anything. what am i doing wrong? (besides letting this be my life...)
control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ctrl.ascx.cs" Inherits="proj.UserControls.ctrl" %>
asdjkldasfjasdfljdfasjklasdfjkl
use:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="page.aspx.cs" Inherits="proj.Admin.page" %>
<%# Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<cc1:ctrl ID="test" runat="server" />
</asp:Content>
Change:-
<%# Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
To
<%# Register TagPrefix="cc1" TagName="ctrl" Src="/path/to/ctrl.ascx" %>
You're missing TagName, which represents the text following the colon in the control declaration. You're also not telling the engine where to find the source file ( Src attribute ). Change /path/to to represent the path from root to your control.
IF you have created custom control then you should add reference of the dll of your custom control ( from choose items from ToolBox of Visual Studio). and then Use the following tag in the page :
<%# Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
If you created User Control then add the following line in your page:
<%# Register src="~/UserControls/ctrl.ascx" TagName="ctrl" tagprefix="cc1" %>
instead of
<%# Register assembly="proj" namespace="proj.UserControls" tagprefix="cc1" %>
use
<%# Register src="~/UserControls/ctrl.ascx" TagName="ctrl" tagprefix="cc1" %>
Make sure you haven't set visible="false" on a panel or div containing your control.
That would've saved me a good hour.
I had to add a new user control to an existing project that already contained a lot of them, and wondered why mine was not rendering. Turns out you can also specify this in Web.config, under configuration, system.web, pages, like this:
<controls>
<add tagPrefix="cc1" tagName="ctrl" src="~/UserControls/ctrl.ascx" />
...which will register the control for the whole project, so you don't have to specify this on every page. Useful for controls that are heavily reused.

Moving code around results in "unrecognized tag prefix or design filter" error

I have a Visual Web Developer 2010 Express Edition Web Application. The Default.aspx starts off as follows:-
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MixedZone.Default"%>
<%# Register assembly="ComponentArt.Web.UI"
namespace="ComponentArt.Web.UI"
tagprefix="ComponentArt" %>
<%# Register TagPrefix="MixedZone"
TagName="NumberInput"
Src="Common/UserControls/NumberInput.ascx" %>
The NumberInput.ascx starts like this:-
<%# Control Language="C#" AutoEventWireup="True" CodeBehind="NumberInput.ascx.cs" Inherits="MixedZone.UserControls.NumberInput" %>
<%# Register assembly="ComponentArt.Web.UI" namespace="ComponentArt.Web.UI" tagprefix="ComponentArt" %>
<asp:Literal ID="Literal1" runat="server" Visible="False"></asp:Literal>
<ComponentArt:NumberInput ID="niNumberInput"
runat="server"
CssClass="valid"
...etc
So far, so good. But I wish to move this code to a different directory. I do this (editing the csproj file by hand) and change the aspx and aspc files accordingly:-
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MixedZone.Default"%>
<%# Register assembly="ComponentArt.Web.UI"
namespace="ComponentArt.Web.UI"
tagprefix="ComponentArt" %>
<%# Register TagPrefix="MixedZone"
TagName="NumberInput"
Src="../MixedZone/Common/UserControls/NumberInput.ascx" %>
and
<%# Control Language="C#" AutoEventWireup="True" CodeBehind="../MixedZone/Common/UserControls/NumberInput.ascx.cs" Inherits="MixedZone.UserControls.NumberInput" %>
<%# Register assembly="ComponentArt.Web.UI" namespace="ComponentArt.Web.UI" tagprefix="ComponentArt" %>
<asp:Literal ID="Literal1" runat="server" Visible="False"></asp:Literal>
<ComponentArt:NumberInput ID="niNumberInput"
runat="server"
CssClass="valid"
...etc
but when I do so, the ComponentArt: is marked with the green underline, and the message
Unrecognized tag prefix or device filter 'ComponentArt'
(about five hundred compilation errors appear as a result). The directory Common\UserControls was moved in its entirety, and nothing else has been changed. Does anyone have any idea what the problem might be and what I might do about it?
I worked around this problem by using SubVersion to include the code in the old location even though it isn't "really" there. I don't like this very much as it seems like a clever-clever trick and a trap for future maintenance. But it won't have the directory if it isn't below the project's, and it won't follow a shortcut if I place one there.

Categories

Resources