I have a webpage that supplies a structure, in it, I include multiple files. For instance:
1. header.aspx which contains a form for logging in.
2. main.aspx that includes another form
3. footer.aspx that includes yet another form.
this is my code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<!--#include file="header.aspx"-->
<!--#include file="main.aspx"-->
<!--#include file="footer.aspx"-->
</body>
</html>
each sub-file has it's on .cs or .vb class page, and each file has a page directive.
I get the expected error:
There can be only one 'page' directive.
I recognize that I address my issue from the wrong perspective. How should I re-construct the structure of my page to allow me to include multiple webforms?
alternitavely, is there (there must be), a better "righter" way to do the sort of thing I am trying to achieve, being: creating one big page that is constructed from many fragments of smaller webpages/webforms.
additionally, I don't want header.aspx to be accessible by typing in its address in the browser domain.com/header.aspx, but rather I always want it to be displayed as part of a bigger webpage.
what the way to go instead of my proven to fail method?
Thanks
p.s
I don't mind doing my own research, but I do need guidance, so, I would appreciate a full example and explanation with all the information I need, but also links to articles will be highly appreciated.
Related
I read examples, but I don't understand what is different between:
<link href="style.css" rel="stylesheet" />
and
<%: System.Web.Optimization.Styles.Render("~/Style/style") %>
why use second example?
Thanks!
The first example is a normal HTML css include link.
The second is part of the System.Web.Optimization bundling package. You can set up bundles to combine multiple stylesheets into a single stylesheet (Note: In debug mode it will still show multiple stylesheets). This reduces the number of trips your page makes back and forth to the server and should speed up page load times.
Here's a tutorial article from the ASP.net site.
I am doing one project in asp .net.Its completed,then the same project will be done in html5. How to convert the .aspx pages and master pages to html 5? Is it possible?If any one know please tell me.
You can technically make the page HTML5 by changing the doctype...
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
It is also recommended that you specify a lang attribute on the html tag and include the meta tag to define your character set.
This won't give you instant HTML5 semantics, but this is essentially step one. Using the right elements for the right kinds of content will be down to you, for example deciding when to use header, article, section, footer instead of plain div elements and so on.
You should also be able to select "DOCTYPE:HTML5" from the toolbar in Visual Studio - I don't know what version you are using, but I think in the previous version you could download a HTML5 language extension, I'm pretty sure it is included by default in Visual Studio 2012.
what you can do... if I understand your question correctly is, rightclick and say view page source and copy your html or install google chrome and the on each page you can go rightclick and inspect element. you can copy and paste the html of each page including the masterpage content. Its a sloppy way but will work if you only want the html
One of the way that i think you can do is to use http://modernizr.com/ kind of framework to switch between html5 and normal html easily .
I would like to have a common head section (for meta tags etc) across all pages. Can I use something like:
<head>
<!--#include file="head.asp"-->
</head>
to do this? Also, must ASP server side includes contain matching tags, or can I open a tag in one include and close it in another?
Thanks.
Yes you can do this. You can put an include file anywhere you want as long as it does not contain something that needs to be at a specific location. E.g. an include file containing <%# language="vbscript" %> must be included at the very beginning of your script.
Secondly it is OK to open a tag in one file and close it in another but normally is poor practice and you have to be careful.
In case you want to check the order of HTML + raw ASP code you can rename the external file from .asp to .shtml. When a shtml file is viewed over IIS, it will process all #include statements but it will not execute the ASP code.
Yes, you can do that. It's safe.
Also, must ASP server side includes
contain matching tags, or can I open a
tag in one include and close it in
another?
The tags don't have to match; you can indeed open a tag in one include and close it in another.
Although, it might not be the best idea simply because it's confusing.
I have created a website in VS 2008 (C#) that is using masterpages.
In the ASPX pages that are based off the masterpage I'm using the # PAGE title directive to set the title of the genereated HTML page.
When I run the page on my development system the title displays correctly i nthe browser. However when I view the source code in the browser the tag is being broken into 3 lines.
<head><title>
My Page Title
</title>
...other meta tags...
</head>
That looks very strage to me. Is there something that I am doing wrong to cause the type of behavior? Will search engines look down on this syntax with the line breaks?
I'm expecting output like this:
<head>
<title>My Page Title</title>
...other meta tags...
</head>
I've never seen that happen before, and I've used MasterPages and Page Titles a few times in the past year.
From an SEO perspective, search engines would ignore the line break in the title and only look at the actual characters between the open and close statements.
This won't make much of a difference. You should be fine either way, and search engines are smart enough to not get confused only a new line or return. Just as long as the HTML isn't malformed, you should be alright.
I'm new to creating html pages etc - but am using VS 2008 just for the editing/intellisense capabilities.
My problem is I have a pure HTML only website (no ASP.NET) and have a fairly extensive header that has to be used in every page. It's frustrating to change the header parts of the HTML across all pages every single time it changes in one. Is there someway I can sort of 'include' the header part HTML in other HTML pages without having to manually cut-paste all-over?
Please note - I'm not using ASP.NET, so I CANNOT and WILL NOT be able to use Master Pages. Is there some other technique is what I want to know - so that when I change the header template in 1 place, it gets reflected in all other. I thought of inline frames, but not sure if that's a crappy way to do that and if it affects SEO
Take a look at Server Side Includes
They'll allow you to edit your header in the one file, which will appear instantly on all pages that include the header file.
Yes, take a look at SSI. Server side includes are a simple way to tell your web server to insert various things at various points in your HTML page.
Example:
<html>
<head>
<!--#include FILE="head.html" -->
</head>
<body>
</body>
</html>
If server side includes don't appear to work as expected, try renaming the page with a .shtml file extension.
Some web servers require that you name your file ".shtml" rather than ".html" in order to enable the parsing of your file.