Showing posts with label WEB. Show all posts
Showing posts with label WEB. Show all posts

A Data Driven Switch Menu On CodeProject.com

Wednesday, December 20, 2006

Yesterday, I write a article on how to make a switch menu with javascript. Today I read a article on codeproject.com named How To Implement a NavigationPanel Using AJAX. The author do a really good work to make a Ajax data driven navigation panel by asp.net and SQL Server. With the source code of the article we can move data source to XML files and so on. 

I decorated the code in my last article. Unfortunately, if you use Firefox to browse it, the style of code looks ugly. I used the open source code coloried tool wriiten by javascript dp.SyntaxHighlighter. I am tring to modify it to satify my requirement better the whole day but with little result.

what a bad day!

......

[阅读全文]

Switch Menu In Javascript

Tuesday, December 19, 2006

I formerly choose Accordion Control in Microsoft Ajax Control toolkit in my application. I like menu with such switching  style. The control is well in it's appearance. For example, we can set frames per second of switching animation and fading transition effect.

However, I encountered the problem when I set  AsyncPostBackTrigger of updatepanel to the LinkButton inside the accordion. If do this, there will be a error at runtime said that  LinkButton1 is not exist. I found a lot of developer have the same confusion at the official forum of asp.net but I can't get answer of it. I think this is may be control name changed when it is in a panel.

I tried another way to solve this problem is to put accordion in a updatapanel. Unfortunately, It still din not work due to LinkButton can't raised event.

Because I can't get the solution of it. I decided to write a switch menu in such style although the self-made one will be simple without any animation or fading effect.

We know we can use CSS style.display attribute to display or hide the div, control and so on. So it's not difficult to make a simple switch menu in Javascript. At first we made menu in html

<ul id="nav-secondary">
    
<li id="Menu1"><a href="#" onclick="SwitchMenu('Menu1','nav-secondary')">Menu 1</a>
        
<ul style="display: none;">
            
<li><a href="#" id="A1">Sub Menu 1.1</a></li>
            
<li><a href="#" id="A6">Sub Menu 1.2</a></li>
        
</ul>
    
</li>
    
<li id="Menu2"><a href="#" onclick="SwitchMenu('Menu2','nav-secondary')">Menu 2</a>
        
<ul style="display: none;">
            
<li><a href="#" id="A5">Sub Menu 2.1</a></li>
            
<li><a href="#" id="A7">Sub Menu 2.2</a></li>
        
</ul>
    
</li>
    
<li id="Menu3"><a href="#" onclick="SwitchMenu('Menu3','nav-secondary')">Menu 3</a>
        
<ul style="display: none;">
            
<li><a href="#" id="A2">Sub Menu 3.1</a></li>
            
<li><a href="#" id="A3">Sub Menu 3.2</a></li>
            
<li><a href="#" id="A4">Sub Menu 3.3</a></li>
        
</ul>
    
</li>
</ul>

SwitchMenu is defined in the Javascript to display or hide the sub menu. note is added. the statement used to set CSS class is optional

var currentMenu;                             //Global variable: current menu
//Parameter obj is the menu you clicked, container is the container layer of menu
function SwitchMenu(obj,container){         
    
if(document.getElementById(container)){  
        
if (currentMenu!=null) {
            //Clear css style of current menu
            currentMenu.className
="";       
        
}       
        //Get the target menu you clicked     
        
var targetMenu = document.getElementById(obj);      
        //Get sub-menu of target menu        
        
var secondaryMenu= targetMenu.getElementsByTagName("UL")[0];    
        
var secondaryMenus = document.getElementById(container).getElementsByTagName("UL"); //get all submenus   
        
if (secondaryMenu==null) {                                  //No sub menu                                 
            
for (var i=0; i<secondaryMenus.length; i++){    
                 //Hide all sub menu                       
                secondaryMenus[i].style.display 
= "none";                          
            
}
            //Set target menu css class
            targetMenu.className
="active";                          
        
}else{                                                                               //Sub menu Exist
            //Click the  menu which sub-menu is hide
            
if(secondaryMenu.style.display == "none"){                             
                
for (var i=0; i<secondaryMenus.length; i++){                            
                    secondaryMenus[i].style.display 
= "none";       //Hide all sub menu                     
                
}
                secondaryMenu.style.display 
= "block";              //Display sub-menu u clicked             
                
targetMenu.className="active";                            //Set target menu css class         
            
}else{                                                  //Click the  menu which sub-menu is displayed   
                
secondaryMenu.style.display = "none";               //Hide it    
                
targetMenu.className="";    
            
}
        }
        currentMenu 
= document.getElementById(obj);     //Set current menu (global variable)
    
}
}

Ok, run it in your browser. it works fine, right?

Maybe additional css make appearance better

/* SECONDARY NAVIGATION - vertical navigation */
#nav-secondary, #nav-secondary ul {position:static}
#nav-secondary, #nav-secondary li {list-style: none;margin:0;padding:0;background:#fff}
#nav-secondary {padding-top:0;border-top: 1px solid #ccc;margin-top: 1px}
#nav-secondary a {line-height:1.8;padding: 5px 0 5px 23px;background: #fff url("images/sprites.gif") no-repeat 10px -695px;font: bold 86% arial;display:block}
#nav-secondary a, #nav-secondary a:link, #nav-secondary a:visited, #nav-secondary a:hover, #nav-secondary a:active {text-decoration:none;cursor:pointer} 
#nav-secondary a:link {color:#000} 
#nav-secondary a:visited {color:#000} 
#nav-secondary a:hover {color:#c00;background: #fee url("images/sprites.gif") no-repeat 10px -695px} 
#nav-secondary li.active a:link, #nav-secondary li.active a:visited, #nav-secondary li.active a:hover, #nav-secondary li.active a:active {color:#c00} 
#nav-secondary li {border-top: 1px solid #fff;border-bottom: 1px solid #ccc}

/* SECONDARY NAVIGATION - 2nd TIER */
#nav-secondary ul {margin: 0 0 1em 23px;padding:0}
#nav-secondary li.active li a, #nav-secondary li.active li a:link, #nav-secondary li.active li a:visited {line-height:1.5;background: #fff url("images/sprites.gif") no-repeat 0 -798px;padding:0 0 0 12px;font-weight:normal;width:auto;color:#000;width:130px;display:block}
#nav-secondary li.active li a:hover, #nav-secondary li.active li a:active {color: #c00}
#nav-secondary li.active li {border: none;margin:0}
#nav-secondary li.active li.active a:link, 
#nav-secondary li.active li.active a:visited, 
#nav-secondary li.active li.active a:hover, 
#nav-secondary li.active li.active a:active {font-weight:bold}

These are the final snap in my FireFox2 and IE7

switchmenu

......

[阅读全文]

Some Tips From Atlas To Microsoft Ajax RC1

Monday, December 18, 2006

These days I am busy on move a old atlas application to newer Microsoft Ajax RC1. During This process I encountered some problem and get some tips.

1. Trigger.ControlEventName in UpdatePanel are modified to Trigger.AsyncPostBackTrigger. I think this is more meanningful. it also add  PostBackTrigger propery to force control refresh in updatepanel.

2. $ changed to $get which is short of Document.GetElementByID in order to conflict to other ajax library such as prototype. Add shortcut $addHandler to listen event of control in client script

3. Page.RegisterStarupScript is moved to System.Web.UI.ScriptManager.RegisterStartupScript. The function add a paremeter of Control.

4. The biggest change affected me is PageMothods which I used to communicate between javascript and server code. Now It must be public and static. In former application I use lot' of un-static method in it. I could not change all of these function to static. so I use RegisterStarupScript  instead of it to pass server data to javascript.

......

[阅读全文]

Auto-Activate ActiveX Controls in The Web Page

Friday, December 8, 2006

Microsoft has made changes to the way that newest Internet Explorer handles some content in Web pages due to security reason. When Internet Explorer encounters a page with ActiveX controls (such as a page using PI-ActiveView to show .pdi file), the control may require a single click to activate. (the newest Internet Explorer represent If user installed security update 912812)

Let us take PI-ActiveView as a example.When you open the page embed .pdi, a tooltip will appear to prompt you that the control should be clicked to first activate before it can interact.

001

When a control is inactive, the following effects occur

  • Dynamic HTML events related to user interaction, such as onblur and onclick, are blocked.

  • The control does not respond to window messages generated by the keyboard or mouse, such as WM_CLICK and WM_KEYPRESS, and so on.

  • An overlay window, created on the control's OLE site, prevents keyboard and mouse messages from reaching the inactive control.

This requirement to click to activate will happen each time you refresh or visit the Web page. This is a annoying to user. Fortunately, developers can rewrite web pages so that users are never presented with a tooltip when they visit the page acording the artilcel on MSDN.

The article's keystone is using script(jscript or vbscript) to load controls from external script files, Then web pages will load interactive controls that respond immediately to user input. Be careful that the script written inline programmatically, for example with the writeln function, the loaded control will behave as if it was loaded by the HTML document itself and will require activation.

The detail way is stated clearly in the above article. I need not to copy them here. ^-^

 

PS: I have a question. The requirement to click to activate ActiveX controls is due to security reason. will this solution make us go back to un-secure time we do not install update and need not to click to activate !

......

[阅读全文]

Tip On Distributing PI-ActiveView Automated ActiveX Installation

Wednesday, December 6, 2006

In previous environment, I always use PI-ActiveView in the machines which has already installed PI-ActiveView and PI-ProcessBook, So I had never care distributing problem until I want to navigate the website use PI-ActiveView to see PDI files embed in it. the result is web page can not display it.

I remember someone ever told that this problem can be solved by automated ActiveX installation because of in the fact it's a ActiveX Control. Open the document of it is my choice and select the setting up automated web installation. Follow the instruction of it. so easy, isn't it?

Open the IE (not firefox for using ActiveX) and modify the security option about "unsigned ActiveX control" to "prompt" because ActiveX file we made has not signed. this is a temporary solution. I suggest u modify it back to prevent malicious ie plugin. This Time I got the ActiveX installation prompt, However when I click sure to install it, there is no response just displaying nothing.

All process seems right following the document. Finally I spent 2 hours to fix the problem and this is the tip what I want to give. Because I placed .cab files in the sub-directory of home directory,  Pay attention to this procedure of cabwizard

acview

Remember to add sub-folder that your cab file placed in to the Full path. What caused me waste 2 hours is here.  In fact, the notion above is clear but I do not carefully read it.

......

[阅读全文]

Add In-Site Search To Your Blogger Beta

Tuesday, December 5, 2006

In my blogger beta default template, there is no in-site search function in my blog and I can not find it in widgets supported. So I am surprised and frustrated that blogger beta has not such normal function. I am not sure whether other default themes has it.

Today I navigated a blog which give lot's of blogger beta hack skills and found a mount of useful information there. However this function is not mentioned in it, is this is a special to me? Fortunately I saw a "search this blog" button in it, then I open the source of the website. I got the search code below.

<form id="searchthis" action="http://sunr.blogspot.com/search" style="display: inline;" method="get"> <input id="b-query" name="q" type="text"/> <p><input id="b-searchbtn" alt="Search This Blog" src="http://sunrrr.googlepages.com/btn_search_this.gif" title="Search this blog" type="image"/> </p> </form>

ok this is the code we want, just change the red code above with your blog address. then add a widget of HTML in template and copy them into it.

Try it!

......

[阅读全文]

Two Simple Hack Tips on Blogger Beta

Friday, December 1, 2006

Because I am a freshman to Blogger Beta. I found two tips to make my new blog better.

The fisrt one is to hide navbar. you can add code below

#navbar-iframe { height: 0px; visibility: hidden; display: none }

to head--<b:skin> section in your HTML. the HTML is under template settings.

The second one is to open new window in Link List widget. By default there is not option that you can config it. so links in Link List widget will open in current window. However this is also could be solved it HTML code.

At first, remember to check the option Expand Widget Templates . Then find the section

<b:widget id='LinkList1' locked='false' title='Blog Links' type='LinkList'>

change links

<li><a expr:href='data:link.target' ><data:link.name/></a></li>

to

<li><a expr:href='data:link.target' target='_blank'><data:link.name/></a></li>

Finnally, Open your blog and try it.

Hope these two simple hack tips is useful to you!

......

[阅读全文]

Wikipedia CD 1.0 (含BT下载链接)

wikipedia-logo维基百科在中国的命运真可谓一波三折,前段时间仿佛看着已经解封了,在大家庆祝了一段时间以后突然又不能访问了。这样的一个好东西在各个方面(政治方面暂且不论)给于我的帮助是很大的,可惜了。

维基百科CD给于我们用另外一种方式接触它的机会,也许有的网友会认为这个是不是专门给中国用户制作的呢?以前我也是这样认为的,但是看了介绍以后发现完全不是这样的。

以下翻译自BitTorrent.com的介绍:

CD包含了2000条投票选择的文章,特别关注于学生和儿童(地理、科学、恐龙、植物和动物)。所有条目是英语维基百科上的为SOS儿童工作的志愿者选取的,适合儿童阅读的并且清除了脚本。CD包含了极少的图片。CD的细节为:

从优秀文章,标志性文章和主要列表(例如所有国家,所有首都等)选取了大约2500篇文章。

垃圾文章、学生难于理解的、模拟两个的文章和肤浅的文章被遗弃或者重新排序。

使用早先讨论通过的存在争议条目的(如基督教等)版本

没有包括文章的链接,外部链接被标识为纯文本,链接表和无用的节被移除.

编辑上的公告和到其他语言的链接等被移除。

维基百科的标志引文SOS没有得到授权所以不会出现在CD中,但是2007版的CD已经得到授权并且会出现维基百科的标志

CD中大概有130页在一个小公告栏中增加了内容,增加的内容关注于SOS儿童(例如 在条目Africa中,增加了内容“SOS已经在大约123个国家开展工作”,见下图。这些提示遵循不影响选择的文章的内容的原则。

SOS_notice_box

最终版本中有一个用于收集目的的完整的SOS儿童网站的镜像。

自动运行拼写检查。 BT下载链接 Wikipedia CD 1.0

PS: 除开Wikipedia CD,这里还有一个Wikipedia的选择叫做Encyclopodia, SF上的一个开源工程Wikipedia on your iPod。可惜我没有iPod要不一定试一下。

......

[阅读全文]