Wednesday, December 2, 2009

Adding HTML/Javascript block scripts

For quite a long time I wanted to know how could I include HTML / JavaScript / Visual Basic scripts (including their original editor colors) into my blog. I looked up on the internet for the answer finding nothing useful. Finally, I got this:

Somewhere I found that I needed a third party program that could do the translation job. This is the one I use now:

However, there are also some others that I haven't try yet. You can find more information here:

Tuesday, December 1, 2009

Identifying if a page is called from a popup

I need to identify whether a page has been redirected from a popup window or it has been redirected from a full page, in order for me to perform a Redirect to "Main Menu" or "Close" from a button.

1. Create two buttons (one that performs a PostBackUrl="/") and another one that executes (window.close() javascript event)

1 <asp:Button ID="cmdBackToMenu" runat="server" PostBackUrl="/" Text="Back to Main Menu" />
2 <asp:Button ID="cmdClose" runat="server" Text="Close" OnClientClick="window.close();"/>

2. Create a javascript event that will be called in the form.onload event.

1 <body bgcolor="#CCCCCC" onload="SettingButton();">

3. The javascript event should be able to identify whether a page was redirected from a popup window or from a full page and depending on the situation make visible or invisible the buttons created in the first step.

1 function SettingButton() {
3 if (opener) {
4 = "visible";
5 = "hidden";
6 }
7 else {
8 = "hidden";
9 = "visible";
10 }
11 }