Author Archives: vincent

SharpDevelop 開發 ASP.NET 2.0 web application 問題

目前測試的版本是 SharpDevelop 3.0 beta,開發 ASP.NET 1.1 的 web application 是沒有問題,如果是 ASP.NET 2.0 的寫法在compile 時會不過,範例如下:(只節錄部份)

Default.aspx

<%@ Page
Language           = “C#”
AutoEventWireup    = “false”
CodeFile           = “Default.aspx.cs”
Inherits           = “Web.Default”
ValidateRequest    = “false”
EnableSessionState = “false”
%>

<asp:Label id=”label1″ text=”On” runat=”server” />

<asp:Button id=”button1″ text=”Toggle” runat=”server” onclick=”button1Clicked” />

Default.aspx.cs

namespace Web {

public partial class Default : Page
{
protected void button1Clicked(object sender, EventArgs e) {
label1.Text=”Off”;

}
}

以上程式 SharpDevelop 在 compile 時會有 label1 變數未定義的錯誤,但是這的確是 MSDN 建議從 ASP.NET 1.1 migrate 到 ASP.NET 2.0 的寫法。目前看到解決的方法是,在 codefile 所指定的程式檔按滑鼠右鍵選 Properties,將 Build action 設為 None,讓 IIS 收到 request 再去 compile 就可以正常運作了。

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Ubuntu 新安裝時常用套件及指令

常用套件

1. 讓 firefox 支援 flash 顯示

flashplugin-nonfree

2. terminal server client 的 VNC 無法選取

必須安裝 vnc viewer, 例如 xtightvncviewer 即可

3. virtualbox 虛擬化套件

這個是依據 open source 版作出來的套件,採 GPL v2 license,使用限制上比較寬鬆,目前只看到 Guest Additions 縮水這個缺點。官方網站上的 binary distribution 其實是有蠻多使用上的限制,如果有授權上的考量,可以用 ubuntu 的套件就好。

這部份需要安裝以下套件:

virtualbox-ose

virtualbox-ose-source

常用指令

sudo -s (成為系統管理員)

aptitude update (更新套件資料庫)

aptitude upgrade (將系統已安裝套件更新至最新版本)

aptitude search (搜尋套件)

aptitude install (安裝套件)

aptitude remove (移除套件)

do-release-upgrade (將 ubuntu 昇級至最新版本,例如 8.10 -> 9.04,必須安裝 update-manager-core 套件)

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

設定 virtualbox 連接 host OS 及 guest OS 網路 – Ubuntu 8.10

主要的概念跟前一篇介紹 virtualbox 在 Windows 下網路設定的文章非常類似,都是運用 bridge 的方法,只是不同作業系統操作方式不一樣,步驟如下:

步驟一、 安裝套件

所需的套件 ubuntu 8.10 都已內建,清單如下

  • virtualbox-ose
  • bridge-utils

步驟二、 ubuntu 網路設定

ubuntu 8.10 內建新版的 NetworkManager 在一般使用狀況下,非常方便,但是仍有不少問題。這例子裡我們採用手動設定方式,並假設你的 ethernet device 是 eth0,bridge device 為 br0,您必須手動修改 /etc/network/interfaces,加入以下設定

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.0.254
bridge_ports eth0 vbox0

步驟三、 virtualbox 網路設定

由於我們的架構是把 virtual machine 的虛擬網卡和 ubuntu 的實體網卡利用 bridge 方式放在同一個網段內,virtualbox 在啟動時必須為每個 virtual machine 建立一個對應的虛擬網卡,通常命名為 vbox0、vbox1,etc。

這部份的設定要修改 /etc/vbox/interfaces,每個 virtual machine 加入一行如下設定:

vbox0 <your username> br0
.

.
步驟四、開放建立虛擬網卡權限

這部份要修改 /etc/udev/rules.d/20-names.rules,讓 virtualbox 每次系統啟動時有權限建立步驟3所定義的網卡

將以下這行
KERNEL==”tun”,                          NAME=”net/%k”
改成
KERNEL==”tun”,                          NAME=”net/%k”, GROUP=”<your user group>”, MODE=”0660″

步驟五、完成設定

完成以上步驟後,重新啟動 ubuntu,讓 ubuntu 完成所有網路設定。接下來只要修改 virtual machine 的網路設定,將 NAT mode 改成 Host Interface mode,interface name 則從 vbox0、vbox1,etc 挑一個填入。啟動 virtual machine 後,將 virtual machine 的 IP 改成 bridge 網段的一個 IP 即可。

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5.00 out of 5)
Loading...

javascript 關閉 explorer popup 視窗時會有警告訊息

最近寫網頁用 <a target=”_blank” href=”url”>新視窗</a> 彈出一個新視窗,在新視窗用 window.close()  指令時,explorer 會警示 是否關閉頁面,還要手動按確定才能關視窗當然不方便,在找資料時才發現一個問題在不同的 explorer 版本還要用不同的解法。explorer 7 之前的版本只要設定 window.opener 不是 null 就好了,但是這個方法 explorer 7 就不能用了,javascript code 如下:

Explorer 6

window.opener=self;

window.close();

Explorer 7

window.open(“”,”_self”);

window.close();

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 3.00 out of 5)
Loading...

javascript 處理 checkbox 問題

印象中一直覺得 checkbox 很難搞,但是又不太清楚問題在那,今天終於知道原因了。關鍵在於處理的是單一 checkbox 或是多個 checkbox,舉個例子:

<form name=”myform”>

<input type=”checkbox” name=”food” value=”cake”>

<input type=”checkbox” name=”food” value=”noodle”>

</form>

要把 2 個 checkbox 都勾選話通常都是利用以下 javascript code

var checkbox=document.forms[‘myform’].food;

for(i=0;i<checkbox.length;i++) {

checkbox[i].checked=true;

}

但是當 form 只有1個 checkbox 時就會出錯,因為當只有1個 checkbox 時第一行 javascript 取得的是一個物件, 而不是物件陣列,只要執行到 checkbox.length 就會有 undefined 之類的錯誤,比較完善的寫法如下:

var checkbox=document.forms[‘myform’].food;

if ( checkbox.length != null ) {

for(i=0;i<checkbox.length;i++) {

checkbox[i].checked=true;

} else {

checkbox.checked=true;

}

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading...