Wednesday, November 18, 2009

fixed my content disappearing in Firefox print preview

Problem

You wrote a web page which the customer will want to print out, which takes 2 or more pages of paper to print. Everything works fine in IE6, but when you go to print it in Firefox, only the first page comes out! The rest of the web page is simply missing from the printer.

Solution

Do you ever get the feeling that these Problem/Solution tricks I write about are from my own experiences as a web developer? You bet! This one took me quite some time to figure out.

The problem was in the style settings of the container of the web page content.

I was using a DIV tag to surround the entire body of the text of the web page to be printed. That DIV tag referenced a CLASS within my CSS that happened to have the element:

overflow: auto;

Removing that little bit from the DIV tag's CSS class completely solved the problem.

I actually didn't need to remove it, and instead I changed the setting to visible.

http://www.fastechws.com/tricks/web/printing-web-page-has-missing-pages-in-firefox.php

Tuesday, October 27, 2009

Nested Master Pages

I have two master pages, one that uses a two column layout, and one that uses a three column layout. So instead of duplicating the entire file (ASP.NET file tags, XML file tags, script tags, css link tags, header and footer controls, etc) I did some googling and discovered that you can build master pages from a base master page (the derived master pages = nested master pages), much like you can create a base ASPX page and use the content place holder control as a template to vary the content. Yay!

One important detail though, is that the nested master pages need to inherit either from the vanilla master page class or a custom master page class (not the base master page class!!!), and the base master page should inherit from the vanilla master page class or a custom master page class

http://msdn.microsoft.com/en-us/library/x2b3ktt7.aspx

This is the parent master file:
<% @ Master Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="Form1" runat="server">
<div>
<h2>Parent Master</h2>
<p style="font:color=red">This is parent master content.</p>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</form>
</body>
</html>

This is the child master file:

<%@ Master Language="C#" MasterPageFile="~/Parent.master"%>
<asp:Content id="Content1" ContentPlaceholderID="MainContent" runat="server">
<asp:panel runat="server" id="panelMain" backcolor="lightyellow">
<h2>Child master</h2>
<asp:panel runat="server" id="panel1" backcolor="lightblue">
<p>This is child master content.</p>
<asp:ContentPlaceHolder ID="ChildContent1" runat="server" />
</asp:panel>
<asp:panel runat="server" id="panel2" backcolor="pink">
<p>This is child master content.</p>
<asp:ContentPlaceHolder ID="ChildContent2" runat="server" />
</asp:panel>
<br />
</asp:panel>
</asp:Content>

And finally, regular page that references the child master file:

<%@ Page Language="C#" MasterPageFile="~/Child.master"%>
<asp:Content id="Content1" ContentPlaceholderID="ChildContent1" runat="server">
<asp:Label runat="server" id="Label1"
text="Child label1" font-bold="true" />
<br />
</asp:Content>
<asp:Content id="Content2" ContentPlaceholderID="ChildContent2" runat="server">
<asp:Label runat="server" id="Label2"
text="Child label2" font-bold="true"/>
</asp:Content>

Friday, October 23, 2009

Hipster: The Dead End of Western Civilization

We are a lost generation, desperately clinging to anything that feels real, but too afraid to become it ourselves.

awesomely simple explanation of javascript:void(0)

http://www.tizag.com/javascriptT/javascriptvoid.php

JavaScript Void 0

Hyperlinks like this one entice visitors to click because they know clicking it will lead them to a new page. However, sometimes when you are making a script, you would like to add functionality to your website that lets a hyperlink to be clicked and perform a useful action like update the sums on the webpage, without loading a new page.


It's these types of programming solutions that will utilize the JavaScript Void 0 programming tool. This lesson will teach you some of the reasons to use the JavaScript Void 0programming strategy in your scripts.



Directly Executing JavaScript in a Browser

Web browsers allow you to execute JavaScript statements directly by entering JavaScript code into the browser's URL text field. All you need to do is place a JavaScript: before your code to inform the browser you wish to run JavaScript. You can play around with this right now by typing something like



  • JavaScript:alert("I'm learning at Tizag.com")

into the browser's URL text field and pressing Enter.



This is useful to you, the JavaScript scripter, because you can now set your hyperlinks's href attribute equal to a JavaScript statement! This means you can remove the hyperlink's ability to load a new page and reprogram it to do your "complete some actions directly on this page" bidding.


This practice can be seen in services like Gmail (Google Email) which does a great deal of interaction with hyperlinks, but has very few new pages loading. Here is an example link that does not load a new webpage.



JavaScript Code:

<a href="javascript: alert('News Flash!')">News Flash</a>

Display:

This is interesting to learn, but it isn't much more than a gimmick. The true power of direct URL JavaScript statements is only unleashed when you use it to return a value. This is where void 0 comes into play.



JavaScript Void 0 Explanation

Web browsers will try and take whatever is used as a URL and load it. The only reason we can use a JavaScript Alert statement without loading a new page is because alert is a
function that returns a null value. This means that when the browser attempts to load a new page it sees null and has nothing to load.


The important thing to notice here is that if you ever do use a JavaScript statement as the URL that returns a value, the browser will attempt to load a page. To prevent this unwanted action, you need to use the void function on such statement, which will always return null and never load a new page.



Simple JavaScript Void 0 Simple Example

void is an operator that is used to return a null value so the browser will not be able to load a new page. An important thing to note about the void operator is that it requires a value and cannot be used by itself. Here is a simple way to use void to cancel out the page load.



JavaScript Code:

<a href="javascript: void(0)">I am a useless link</a>

Display:

Simple JavaScript Void 0 Useful Example

This example shows how you would return a value using the void operator. myNum is a variable that we set to the value 10. We then use the same variable myNum in an alertoperation.



JavaScript Code:

<a href="javascript: void(myNum=10);alert('myNum = '+myNum)">
Set myNum Please</a>

Display:

Tuesday, October 20, 2009