Printing Html with razor view engine - html-helper

Is #MvcHtmlString.Create(Html.SomeHelperThatReturnsHtml) the prefered way of printing Html with Razor view engine?

I've been doing this:
#( new MvcHtmlString(Html.SomeHelperThatReturnsHtml) )
(sorry, not at my workstation to test code.)

Related

ddrmenu razor doesn't show anything in dotnetnuke

For our website we want to use a megamenu that is created with razor.
In the Gravity skin folder of DNN, we have created a folder called MegaMenuNav and we have added our MegaMenu.cshtml and menudef.xml into it.
We have downloaded the ddrmenu example and used it like this:
<dnn:MENU ID="MENU" MenuStyle="MegaMenuNav" runat="server" NodeSelector="*"></dnn:MENU>
we get no error, but nothing is shown as well.
All of the example menus that use token or xslt, such as Dropdown and Mega2DNN are shown, but when we use Razor menus, nothing is shown.
For testing, we added a simple text inside our MegaMenu.cshtml, but again we got no result
Is there anything to do with dotnetnuke?
BTW, we are using .Net 4.5 and Dnn 8.0.2
Thanks in advance

How to setup a Sencha ExtJS project currently built for desktop also work for mobile?

We have been developing using the default classic build descriptor so far to build dynamic web pages for desktop.
Now we need on the same application to work with mobile but not necessarily have the same home page on desktop or mobile load.
The user visits the page http://example.com using a desktop browser. Then he sees the view layout for the desktop
The user visits the page http://example.com using a mobile browser. Then he sees the view layout for the mobile (could be a total different view file)
We found this page inside documentation without much help: https://docs.sencha.com/extjs/6.0/core_concepts/tablet_support.html
Actually a page that is currently working fully ok on desktop when switching to the Chrome Simulator (setting for example the Apple iPad simulator) we get the following errors in the console:
We need the few steps that are necessary to setup it correctly.
When you create a brand new application in ExtJS 6, you acess sencha cmd and call: "sencha generate app NameApp ../folderApp"
Then, the following structure is created: Click here to see the structure
I don't know about the structure your code was created, but in order to work on desktop and mobile devices, it need to be in this structure generated by sencha cmd.
After to get this structure (generate a new application is a better practice for that) you need to put the "rigth model of extjjs 6.0" in your mind. ExtJS allow MVC or MVVM architetures. MVC architeture is basically controlled by a grand controller that can control all components of your application. In other hand, MVVM architeture have a controller for each view - it is instanciated when view is instanciated, and destroyed when view is destroyed. This architeture is recommended in ExtJS, especially in the lasts versions.
You have now to transfer the code done in your actual aplication to the new application and architeture. Put all your view structure in NameApp > classic > src > view. Open a new folder for each view. This folder should contain the view, and the controller for this view. For example, let's create a list view:
NameApp > classic > src > view > list > List.js
NameApp > classic > src > view > list > ListController.js
And so on...
Now you can create mobile views and controllers separated, on mobile > src > view folder, following the same model followed in classic, but you have to use components from mobile toolkit of course.
Until here, you have a separated mobile and classic app in the same code. But you can use the power of ExtJS 6 by extend generic classes from app folder, in order to optimize your code. For example, you can create a generic controller for an specific view, that will be extended in classic and modern folders:
NameApp > app > view > list > ListControllerGeneric.js
Ext.define('NameApp.app.view.list.ListControllerGeneric', {
extend: 'Ext.app.ViewController',
//here you put code using in modern and classic both
});
NameApp > classic > src > view > list > ListController.js
Ext.define('NameApp.app.view.list.ListController', {
extend: 'NameApp.app.view.list.ListControllerGeneric',
//here you put code using in classic only
});
NameApp > modern > src > view > list > ListController.js
Ext.define('NameApp.app.view.list.ListController', {
extend: 'NameApp.app.view.list.ListControllerGeneric',
//here you put code using in modern only
});
One important thing to avoid crashes is to create all the views from the classic folder into the modern folder even if you do not actually use them on mobile. In addition when using both desktop and mobile you need sencha app watch modern to test both classic and modern but you need sencha app build to build both (or sencha app build to build specific).
I hope this explanation can be useful for you.
Thanks
The question is very broad, and I can't see what you have done and why it fails. The touch support named behind your link is for the classic toolkit, not for the modern, so if you want to use modern toolkit, forget about that link.
As with most of these framework changes, you are best off creating a new application environment (sencha generate app) and then porting (copying) your source code over. When generating a new application environment, don't provide a toolkit config, so a universal app is created.
Then don't just put all the code into a single directory. You have to dissect your existing code files into two parts: "Used for both toolkits" and "Used for classic only". Views are usually classic only, while some of the models and stores may be universal. The two parts go into two different directories: src for the universal part and classic/src for the classic part.
Only then write the views for modern toolkit (put them into modern/src), and everything should compile fine.
Im very new to sencha, but i want to point out that using:
sencha app watch
tryied to find all my files on the app folder, even if i use "?modern" or use the chrome devs as a mobile user-agent.
Using:
sencha app watch modern
solved the issue. This command will check for the user-agent or the "?modern" and "?classic" tag and request the correct files.
This answer was originally in #Albanir Neves response, i just made it more clear here.

AngularJS refresh PHP templates

I have a login system maded with AngularJS. Now I want that if somebody is not logged in the template is blank. If somebody logs in the template will continue. The problem is that when you load the page the templates loads also. So when you log in you get a blank page, you need the reload the page and then its working.
Is there a function that refresh the template? So that you don`t have to reload the page?
When you use Angular it's best to have the web server serve static content (images, css, js, and static html) and data (almost always JSON).
In your case I would always serve the template and use ng-show and/or ng-hide to toggle the template display. Here's a simple example:
Instead of
<?php
echo "Hello " + $name;
?>
Do this
greeting.html
<div ng-show="authenticated">{{name}}</div>
greeting.json web service (I'm not a php person, my php might not be entirely correct):
<?php
json_encode($name)
?>

Silverlight: Navigation app template - can we have cleaner urls? And urls like asp.net MVC / Routing has?

I have just created a new silverlight app using Silverlight navigation template. All went well and its working :-)
But the url has an extension of aspx ... can we not remove like asp.net MVC has done?
SilverlightApplication1TestPage.aspx
The next thing that i found strange is how it appends the page name, it uses # symbol like so
SilverlightApplication1TestPage.aspx#Home
I thought it would be more natural to do this (also like asp.net mvc does)
SilverlightApplication1TestPage/Home
SilverlightApplication1TestPage/About
Is there a kind of work around or updated tamplete of some kind
Or its not possible?
Thanks
I'm using Silverlight with Asp.Net MVC and here is a sample URL: http://localhost:37920/#/AdvancedSearch. When I was using straight Asp.Net then yeah I had .aspx files in it. It Still isn't what you really want but gets you closer maybe.
The bottom line is: no. To simplify it everything in a URL prior to the # belongs to the server and everything after the # belongs to the client.
A Silverlight application exists entirely with with in a single URL (page) from the servers perspective. When you use the Silverlight navigation framework you are moving about within the app inside this single HTML page.
If the # is removed there would be fetches made to the server and the results would replace the existing page, the current SL app will be unloaded to be replaced with the resulting content. Even if that resulting content is the same SL app but directed to a different context it would still unload the app and reload it.
The use # is merely a means for navigation within the Silverlight app to be tracked within the browsers navigation history. The browsers own back button will then operate in a way that doesn't surprise the user.
THanks everyone for comments, it got me thinking... and i think i have fixed it.. and found a solutions using asp.net 4.0 routing...
Add a global file to the asp.net project and then add this to application start
// Code that runs on application startup
RouteTable.Routes.MapPageRoute("SilverlightRoute",
"MyApp",
"~/SilverlightApplication1TestPage.aspx");

Rendering chart inside jsp without storing

I have created a chart using JFreeChart inside a JSP. I want to render this chart in a webpage using JSP, without storing the image as JPEG/PNG file. This is in the google app engine environment which does not support writing to disk.
I tried the following:
java.awt.image.BufferedImage chartImage = targetChart.createBufferedImage(600,400);
ServletOutputStream out1 = response.getOutputStream();
JPEGImageEncoder encoder= JPEGCodec.createJPEGEncoder(out1);
but ended up getting a
java.lang.IllegalStateException: STREAM
BTW, java.awt is also not allowed in the app engine environment. What options do I have for solving this problem?
I abandoned the JfreeChart approach and used the Google Chart API to build the pie chart.Ex.
<IMG SRC="http://chart.apis.google.com/chart?chco=FF3300,66CC33&cht=p3&chl=A|B|C|D&chs=500x200&chd=t:10,40,30,20&chtt=Your%20Chart"
Just to clarify, the above JSP code is for JSP that's specified in <img src="...">, right?
Make sure you have no spaces / new lines anywhere outside of <% %> tags on that page, otherwise they'll be written to JspWriter which would prevent you from obtaining OutputStream. I'm pretty sure that's the problem you're having now.
You could also use Flash based charts, like amcharts
http://www.amcharts.com/.
See my demos at
http://aaron.oirt.rutgers.edu/myapp/amcharts/doc
I tested this under GAE and it worked fine.

Resources