Page is loading without rendering style.css - c#

Here is my project directory where I have
style.css
under Content and
image.jpg
under Images
Login.aspx page is default page.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="LoginDemo.Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="~/Content/style.css" rel="stylesheet" type="text/css" media="screen" runat="server" />
<title>LOGIN</title>
</head>
<body>
</body>
</html>
And here is CSS
*{
margin:0px;
padding:0px;
}
body{
background-image:url(Images/image.jpg);
background-size:cover;
background-attachment:fixed;
font-family:Times New Roman ;
}
Page is loaded successfully but without loading background image. Please help me. I read different article and as per suggested solutions I do the same steps but still there is problem.

Images is not in the Content folder. so in your css, you should go back a folder:
background-image:url(../Images/image.jpg);
Note the ../ before Images folder in the path

put a single quote before and after your image path,and also use (..) to refer up directory, so correct your css code with these lines:
*{
margin:0px;
padding:0px;
}
body{
background-image:url('../Images/image.jpg');
background-size:cover;
background-attachment:fixed;
font-family:Times New Roman ;
}
and where is your webpage location ? is it in a directory ?

Create an error in style.css file, compiler didn't listening the file. clean the solution and Rebuilt it again. Surely It will work.

Related

Stylesheet not properly loading, or linking

I can't get my style sheet to work in Visual Studio. I have tried quite a few things. Here is my code as it currently is.
Index File (Home Page)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title>Index</title>
<link href="indexStyleSheet.css" rel="stylesheet" />
</head>
<body>
<h2>red</h2>
</body>
</html>
CSS (The file type is .css)
h2 { color: red;}
Screen shot of file hierarchy
As your css file is in the same directory as your index.html, you don't need to specify a path starting from the root of your project.
This should do it.
<link href="indexStyleSheet.css" rel="stylesheet" />
Edit:
Also, I didn't catch that immediately, what is most likely the cause of all your problems is that your h2 isn't inside the body tag !

What do I have to do to get my ASP.NET MasterPage to work on my server?

I followed some examples in my ASP.NET 4.5 in C# book for Master Pages. So I made a more complex site using them, and it all works locally. But when I push it to my remote server, it is saying the file cannot be found. So I made a more basic master page in Visual Studio 2015 to check. And it works locally, but when pushed to the remote server, it still does not work. I couldn't find any answers online either. I've tried some different urls thinking I was using the wrong url too. I've used
myWebSite.com/TestFolder/MasterPage.master
myWebSite.com/TestFolder/
myWebSite.com/TestFolder/MasterPage
So I'm not sure what I'm doing wrong. Any help would be greatly appreciated.
The code for my master page looks like this:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Tester</title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<h1>This is a test of the master page.</h1>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
I fixed it. I made sure that the file path to the CodeFile in the header was "./MasterPage.master.cs" and the MasterPageFile reference in the header of the content page was "./MasterPage.master" not "~/MasterPage.master".
The url also worked just as myWebSite.com/
Thank you for the help anyways. Much appreciated.

Obfuscate aspx pages - c# codes are inside aspx files

Please take a look at this link :
http://forums.asp.net - Obfuscate aspx pages
I have the same problem and my problem is how can i obfuscate aspx pages with c# codes inside?
I know for .net dlls we can use :
Dotfuscator
Or
Other third party programs...
But what about aspx files with c# codes and my purpose is to obfuscate c# method names and strings in that file!
EDIT :
My aspx file is like this :
<%# Page Language="C#" Debug="true" trace="false" validateRequest="false" EnableViewStateMac="false" EnableViewState="true"%>
<%# import Namespace="System.IO"%>
....
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
C# Codes...
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title></title>
<style type="text/css">
...
</style>
<script type="text/javascript">
...
</script>
</head>
<body>
<form id="" runat="server">
...
</form>
</body>
</html>
obfuscation of aspx(html) part is not important for me and only want to obfuscate C# Codes...
Edit 2 :
What is your purpose?
Are you crazy?
No, i'm not.
sometimes i don't have access to Visual Studio and want to write a little project very quickly in a single file with c# codes and gave it to my customer.
Based on what you said, "how can i obfuscate such these files (aspx codes + c# codes in one file)?" You cannot do that. You can use the Code-Behind Model which is where you C# code in a separate file.
Code-Behind
Code-behind refers to code for your ASP.NET page that is contained
within a separate class file. This allows a clean separation of your
HTML from your presentation logic.

Web Application App_LocalResources Not Working

I have a number of aspx pages contained in external assemblies which are loaded via a custoer PathProvider, all works fine with the exception of local resources for the pages.
So for example, I have a project Paul.Pages, within Paul.Pages there are a number of aspx pages, these are all embedded resources and are loaded view PaulPathProvider.
I have page welcome.aspx which has a single lable welcomeLable (and I have set the Text property to "Hello World") in Paul.Pages, I have generated local resources for this page and now in Paul.Pages I also have a App_LocalResources folder with welcome.aspx.resx, in the .resx file I have welcomeLabelResource1.Text = "Hello Paul".
When the page loads I would expect to see "Hello Paul" but actually it displays "Hello World" implying the resource string is not being loaded, I have tried setting the welcome.aspx.resx to Embdedded Resource but it makes not difference.
Any help is much appreciated, this is driving me nuts.
Addiontal Info
So the welcome.aspx is contained in an assembly OliveERP.Common and is named welcome.aspx, this has Build Action = Embedded Resource as it is loaded using a custom path provider. The OliveERP.Common has a App_LocalResources folder containing welcome.aspx.resx the page html is
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="welcome.aspx.cs" Inherits="OliveERP.Common.welcome" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label runat="server" ID="welcomeLabel" Text="Hello World" meta:resourcekey="welcomeLabelResource1" />
</div>
</form>
</body>
</html>
but page still displays Hello World not Hello Paul
seems the following is your problem
in the .resx file I have welcomeLabel.Text = "Hello Paul".
<asp:Label runat="server" ID="welcomeLabel" Text="Hello World" meta:resourcekey="welcomeLabelResource1" />
When your label's resourcekey is welcomeLabelResource1 then in your resx file you should have a resource string welcomeLabelResource1.Text for the Text property.
May be you have your resource files as "Embedded Resources" Try making them "Content" files.

Display simple c# in "sharepoint online"

I am using "SharePoint Online" and I'm new to it. I have descend programming background and I need more Info on customisation of this service. I've never worked with .NET before (WHAT?!), but I would really like to learn more about C# and it's use in the industry. I have full access to SharePoint Designer and I have Visual Studio 2008.
1) How can I implement simple c# code on SharePoint web page?
2) How to import and use c# classes on SharePoint page?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%# Page Language="C#" %>
<%# Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta name="WebPartPageExpansion" content="full" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 4</title>
<meta http-equiv="X-UA-Compatible" content="IE=10" />
<SharePoint:CssRegistration Name="default" runat="server"/>
</head>
<body>
<form id="form1" runat="server">
</form>
</body>
</html>
This is a brand new, empty .ASPX page generated by "SharePoint Designer". How can I import and display simple "Hello World", c# code on it?
Thank you very much in advance
Inside your <form> tag, insert this line:
<form id="form1" runat="server">
<% Response.Write("Hello World"); %>
</form>
Have fun learning C#
You cannot run server-side scripts on your ASP.NET pages in SharePoint online. It is not allowed and will tell you as much when you try to do this.
If you had an on-premises site, you could modify a setting in web.config to enable this, but that is beside the point.

Categories