I have small question that I can't quite figure out solution myself or find any answer (or clue) on web. Let me explain my problem.
I uploaded files to my SQL server using ASP.NET application.
The thing is, I'd like to view content of those files on aspx page.
Files are only code files (.cs, .aspx etc), basicaly txt in different technologies. I'd also like to use highlight.js to view those files as code.
Try something like this:
UI:
Import required hightlight required js/css files in .aspx page.
<link rel="stylesheet" href="/path/to/styles/default.css">
<script src="/path/to/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
Have one label/textarea to show code of .aspx/.aspx.cs file under
<pre><code class="cs"><asp:Label id="lblCode" runat="server"/></code><pre>
Server side:
In Page_Load() make db call to get content of .aspx/.aspx.cs files from database and set to label.
protected void Page_Load()
{
this.lblCode=DataAccessLayer.GetCode();
}
Check below links for more details about highlight.js
https://highlightjs.org/usage/
http://highlightjs.readthedocs.org/en/latest/css-classes-reference.html
Related
I am storing the content for my page in a sql server database. When i load the content onto the page i have a tag:
<img src="~/Images/Course/html.jpg" />
The html is being rendered using #Html.Raw(content).
when the page loads i get the error:
GET http://localhost:51249/Course/Index/~/Images/Course/html.jpg 404 (Not Found)
I dont know why it does this. Is there any way to have images stored in files within the project, then when loading the html from the db the local linking works? Do I have to host the images somewhere and link to them via https? Any help would be great.
Fixed it - just remove the tilda from the value in the database. Here's a small sample code in the HTML to reproduce the same problem:
<img src="~/images/house.jpg" />
#{
var something = "<img src='/images/house.jpg' />";
}
#Html.Raw(something)
The first line displays the image direct from the location, using the tilda, which .net resolves to the root of your project.
The second line doesn't use the tilda, which automatically comes from the root of the project, but leaving the tilda in messes up.
Fix: delete one character from the HTML stored in the database.
I'm trying to port THIS pasge and its HTML5 animation to a winform.
What I did is copied and added the index.html and all the css and js file to my project. This is how my project directory looks like
And then I'm trying to load the html file into my webbrowser object using this code snippet
private void Form1_Load(object sender, EventArgs e)
{
string curDir = Directory.GetCurrentDirectory();
this.webBrowser2.Url = new Uri(String.Format("file:///{0}/index.html", curDir));
}
And I have set properties of all the file to Copy Always
Now when I run the project I get a script error message and upon pressing Yes
it loads the page but only background is displayed and the animation is lost!
please help!
PS: I've changed
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script src="js/ThreeWebGL.js"></script>
<script src="js/ThreeExtras.js"></script>
To
<link href="main.css" rel="stylesheet" type="text/css" />
<script src="ThreeWebGL.js"></script>
<script src="ThreeExtras.js"></script>
in index.html file
Screenshots of two script error that I'm getting--
It works in IE10
The *.js files need to be in a js folder. Either create the folder and move them or edit the html file.
EDIT1:
Does it work if you point it to "http://www.script-tutorials.com/demos/177/index.html"?
EDIT2:
Add:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
in the html head section.
EDIT3:
I tried on my machine and it's the same behavior. But the page does run fine in Internet Explorer 11. Maybe the WinForms control uses IE engine in some compatibility mode.
I would use http://www.awesomium.com/
The webbrowser control is just an instance of IE - that page doesn't work for me in Internet Explorer so it's unlikely to work in the embedded browser. Search for webkit net - might give you better results. I'm tempted to ask why you want to do this but I'm sure you've got a good reason.
Got it working! Basically the set up works fine. Just had to open main.css file and comment out all the footer properties to get rid of the footer and found another script ref which was pointed to js/script.js had to change it to script.js
Now how can i increase the framerate so that it doesnt stutter? Theres a lag at the moment
I am trying to help friend with his website which is written in asp.net. I am newbie in asp.net but I know php and mysql. Right know I am trying to figure out, how to declare which page (something.aspx) is shown in ContentPlaceHolder.
For example:
I have one master page (web.master) on which I have:
< asp:ContentPlaceHolder id="cpMainContent" runat="server">
Then I have many content pages (f.e. article.aspx, section.apsx) on which I have:
< asp:Content ID="Something" ContentPlaceHolderID="cpMainContent" runat="server">Some content
So my question is, how the website knows which .aspx file to open? If I open my friends website, I found out, that in cpMainContent is content from file section.aspx. If I make new page, like section2.aspx, how should I let the website know, that it should use the new created page?
Thank you very much for responses.
When creating a new page, you give it a name and before you press "ADD" you can check off to "Select Master Page". It will bring up a dialog box of all master pages in the project and you can select one. Easy as that!
Master pages are not accessed directly by the user. Redirection can be performed by adding the directory pathto the anchor tag to other pages( content pages associated with master pages/ not associated with master page ).
I'm converting a desktop application that hosts HTML content into an online application. I have various large pieces of prebuilt static html that need to be included in an MVC page depending on user actions. Each of the static html pages includes at least one img tag that references a file that, in a Web Forms page would be located in the same directory. Here's a very simplified example:
Static html:
<html>
<!-- Large chunk of html -->
<img src="logo.gif" >
<!-- More html -->
</html>
SampleController:
Dim html as String = GetFileContentAsString("~/Content/Sample/Static.html")
ViewBag.StaticHTML = PrepareHTMLContent(html)
View:
#Html.Raw(ViewBag.StaticHTML)
The result of the above is a page (e.g. http://localhost:12345/Sample) with a broken image link in the middle of the HTML. I'm already preprocessing the html where possible to strip out useless tags and insert Javascript and CSS links but preprocessing the image paths is unreliable because they could be anywhere in the static html and are quite likely to be inconsistent or otherwise quirky.
So how can I place (or create) the image file in the right location for the static html to pick it up? Is there any other option (bearing in mind that I also need to link CSS and JavaScript files and that the static html has a bunch of other files associated with it that need to be kept in a single location)?
Or is there a way to define or override the location the dynamic MVC page is built?
Easiest thing would be to have /Sample return an HTML page that simply loads /~Content/Sample/Static.html into an iframe so that the browser will resolve relative paths in static.html to be within /~Content/Sample/
I know you can't use asp net server tags in an external javascript file. This is a bit of pain, because it forces you to declare your variables that need ClientID in the aspx page and then you refer to them in the external javascript file. Not very clean. Currently I use script manager's composite script to register my scripts... It would be nice if I could have the script injected and the server tags processed as if it was part of the page. Is this possible?
I know there is RegisterClientScript but this doesn't seem to honor the script tags either. I'm wondering if there is a solution someone has come up with to just pull the contents of the javascript file and shove them into the aspx page before it's processed so that the server tags can be processed. I've looked all over the web and don't see any good solution to this beyond using the server tags in the aspx page or generating the ids of controls, etc. server side and generating script.
I know you can't use asp net server tags in an external javascript
file
You can create an ASPX page to generate dynamic javascript
<%# Page Language="C#" AutoEventWireup="false"
CodeFile="script.aspx.cs" Inherits="scripts_script"
EnableViewState="false" StyleSheetTheme="" %>
function test() {
testinfo.innerHTML = "<%= MyVariable %>";
}
Make sure to set StyleSheetTheme="" otherwise the runtime will insert a <head> which you don't want
And in the code behind set the ContentType to application/x-javascript
using System;
public partial class scripts_script
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.Response.ContentType = "application/x-javascript";
}
}
Now you can use this ASPX page as if it were a .js file.