How to move a Skin Object Control with Resources to a DNN Module and building the module without namespace errors? - namespaces

I have created a DotNetNuke module with code I have copied from a skin file (Skin Object).
I am trying to make this a module so that I can drop it on any page and move and manipulate it any way I like.
I have managed to get the module to work, but only after it failed to find the tagprefix after installing the module and refreshing the page.
The problem is that Visual Studio is complaining that it can't find the namespace, but these resources are defined in the skin file.
<%# Register TagPrefix="dnn" TagName="USER" Src="/Admin/Skins/User.ascx" %>
<%# Register TagPrefix="dnn" TagName="LANGUAGE" Src="/Admin/Skins/language.ascx" %>
<%# Register TagPrefix="dnn" TagName="LOGIN" Src="/DesktopModules/LoginSkinObject/ParrotLoginSkinObject.ascx" %>
<div class="loginlinkwrapper">
<em class="fa fa-user"></em><dnn:USER runat="server" id="dnnUSER" CssClass="login" />
<em class="fa fa fa-lock"></em><dnn:LOGIN runat="server" id="dnnLOGIN" CssClass="login" />
<dnn:LANGUAGE runat="server" id="dnnLANGUAGE" showMenu="False" showLinks="True" />
</div>
I just need a way for Visual Studio to build the module without complaining about the namespaces.
This is the error I get in the Output window (Please note that we only have our DesktopModules in VS to keep everything neat:
This is where the Resources are already defined in the Skin File.
Now, I did try to copy the resources from DNN and adding it to the Project, but for some reason it can't find it. Is there perhaps a web.config setting I can add?

Any particular reason you're not doing the references with ~
<%# Register TagPrefix="dnn" TagName="USER" Src="~/Admin/Skins/User.ascx" %>
<%# Register TagPrefix="dnn" TagName="LANGUAGE" Src="~/Admin/Skins/language.ascx" %>
<%# Register TagPrefix="dnn" TagName="LOGIN" Src="~/DesktopModules/LoginSkinObject/ParrotLoginSkinObject.ascx" %>
You also should double check that IIS doesn't have an application/virtual directory on the /desktopmodules/ folder as that can sometimes happen and cause problems.
Another thing you might try is simply close the ASCX files when you build, and see if Visual Studio stops chirping about them.

When referencing these skin objects like this inside of a DNN Module it can get really complicated as Visual Studio doesn't know where to go find the type of the referenced element.
Typically, if you go into your .designer.cs file you will see that the element gets tagged as a Generic control of some type, you will need to modify this to reflect the proper type/namespace reference for the controls. This additionally does require DLL references as part of this, so be cautious for circular references depending on how you have things architected.
This isn't an issue for the skins, as they are not using a code-behind file and are processing these truly dynamically by loading the referenced src attribute.

Related

Is it possible to load a specific 2sxc module in a DNN skin?

DNN Platform 9.3.2 /
2sxc 10.25.2
I have a DNN website that uses 2sxc. I created a "Notification Bar" content type and c# razor template that I use to display special notifications to the user. This module is meant to display on every single page of the website. I used the "Add Existing Module" functionality to manually add the module to every page but it's a bit cumbersome and I run the risk that my Content Editors move the module by accident, delete, or forget to add it to new pages.
Is there a special 2sxc skin object that I can use inside of my .ascx DNN skin to load a 2sxc module so that I don't have to add it to every page through DNN? Apparently there is one in DNN OpenContent.
(More than just the notification bar, this would be super useful for the site's header or footer that gets occasionally updated. For example, social media links, contact info like address or phone number, or other links that aren't part of the DNN pages menu.)
There are two ways
create a pane for this specific module (it's the easiest to edit and work with) and just show the module on all pages
create the module on a hidden page and then inject it into the skin, using the Factory to get the CmsBlock - see https://docs.2sxc.org/api/dot-net/ToSic.Sxc.Dnn.Factory.html#ToSic_Sxc_Dnn_Factory_CmsBlock_System_Int32_System_Int32_
Daniel, this is how we did it in the past. I notice your call is similar but simpler (above in the comments). Is that because the API changed somewhere after v10?
<script runat="server">
// get 2sxc to Render() the output from the module on the SITE/Manage Flyout Links page
private IHtmlString RenderFlyoutMenu()
{
return ToSic.SexyContent.Environment.Dnn7.Factory.SxcInstanceForModule(3354, 606).Render();
}
</script>
<%=RenderFlyoutMenu() %>

For what is used ' <%#data: ... ' in embedded code blocks?

I am trying to insert images in a GridView Table, the image is saved as base64 in a SQL DataBase, I found in a youtube video, that you can retrieve and make the data binding with an embedded code block
<%# ... %>
They are using also this:
<DataItemTemplate>
<asp:Image ID="Foto" runat="server" ImageUrl='<%#"data:Image/png;base64," + "ImageData" %>'></asp:Image>
</DataItemTemplate>
For what is the data:Image/png, is it just format? and how is it called to search it online?
Thanks in advance.
Video consulted: https://www.youtube.com/watch?v=sFkeJb7E_rk&t=427s (min 4:15)
data:Image/png;base64,... is called data URI scheme or RFC 2397.
There're two parts of the solution you are using:
The part using <%# ... %> is used by ASP.NET to embed C# or VB code inside your ASPX page. In your example you are promoting a string to your HTML page with the data URI printed.
The data:Image/png;Base64,... is actually used to embed a binary image inside your page. You can look at this reference more details and examples (if you do not like the RFC standard document - which is sometimes harder to read).

how to add form to application.html.erb page ruby

I'm quite new to ruby and I'm trying to put the form to add a new post to the "application.html.erb" page.
Somehow I can't get it to work by just copying the code from the "app/views/things/_form.html.erb" page, and also I can't seem to get it to work by copying the code from the "app/views/things/new.html.erb" page.
If I do that I get the error:
First argument in form cannot contain nil or be empty
The error points towards:
<%= form_for(#thing) do |f| %>
This is a code that I find in the "app/views/things/_form.html.erb" page.
Can anybody point me in the right direction? To be honest, I don't even know where to start looking for the answer.
I think you should take a look at ruby on rails MVC model first, and also go through a basic tutorial. Just a quick review of you question:
application.html.erb is usually in the layout folder of rails,
it's job is to provide a root template/layout for the whole project if not specified.
usually you don't want to put any code that is not commonly
needed by all pages.
the reason it is giving you the error First argument in form cannot contain nil or be empty is because, the helper method form_for is expecting the controller to provide a #thing to the view file application.html.erb, in your case, it is obvious that #thing is not exist in your controller or your ApplicationController.
The #thing should be initialized in your controller. I suppose you've got a things_controller.rb that has a new action in it. In this action, controller should initialize #thing and therefore it is visible in app/views/things/new.html.erb.
You really shouldn't put forms in application.html.erb, but just to make the error disappear, you could do
<%= form_for(Thing.new) do |f| %>
(assuming you've got a Thing model in app/models/thing.rb).
This way you'll initialize an instance of Thing right in your application.html.erb view.

Rails default link when using hash sign

I'm working on a Rails project on the file located at myserver/myNewProject/here.html, and when I have an HTML link like
...
it jumps back to my old project at myserver/myOldProject#test. This is not good, since the old project has nothing to do with the new project.
This is probably because I copied over some code from my old project, but I don't know which part is causing this. How can I correct this behavior?
Use the :anchor attribute in the link_to:
<%= link_to('some link', posts_path(:anchor => 'test'))
Will generate a link like:
some link
See the docs for all the options link_to takes:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html

understanding logic flow Struts

first off, i'm new to Struts and i have been following the tutorial here. I understand the set-up of files, and web.xml.
index.jsp:
<%# taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<logic:redirect forward="helloWorld"/>
However, when it comes to the opening of index.jsp, i am at quite a loss. From index.jsp, how does it call the class com.vaannila.action.HelloWorldAction? I know that index.jsp calls the forward=helloWorld but does it mean that it looks for a forward name="helloWorld", which is in <global-forwards>?
Let me know how I can further improve my question, since this is my first.
Correct; it redirects to whatever forward is named "helloWorld".
In this case, that's a forward that runs an action that sticks a value into a form.
You'll likely want to refer to the Struts 1 tag docs, it'll be quicker than asking here every time.
If you can avoid learning Struts 1, I would: it's pretty antiquated on almost all fronts. Frameworks like Struts 2 and Spring MVC dominate Java-framework-based web apps, while things like Grails, Play, Ruby on Rails, etc. dominate JVM-based web apps.
Line 17 of the config file in the tutorial you link to starts:
<action path="/helloWorld"
type="com.vaannila.action.HelloWorldAction"
name="helloWorldForm">
<forward name="success" path="/helloWorld.jsp" />
</action>