2008年6月26日 星期四

silverlight 在 windows server 2003 的問題

當要部署 silverlight 在 server 2003 時,發現作品都無法出來,畫面一片漆黑,見鬼了,明明是可以執行的,卻這樣子冷冷的不回應。

原來,是 server 2003 預設是不支援 .xaml 檔案的 MIME 格式。所以,就要手動去 IIS 上設定了。

到 IIS->預設網站->內容->HTTP 標頭->MIME 類型->新增

在副檔名、MIME類型 欄位都填入 .xaml 即可。


參考網址:
1. silverlight question
2. panda & polly 的努力

2008年6月12日 星期四

Store Procedure 的預設值

如果想要在 Store Procedure 裡面使用預設的參數,可以在參數宣告後用 = 號來指定。如此,日後呼叫這支 Store Procedure 時,就可以省略一些參數的輸入或是只需要輸入幾個特定參數就可以。


/* Store Procedure 範例 */

CREATE PROCEDURE [dbo].[pr_test]
@p1 nvarchar(20) = '11',
@p2 nvarchar(20) = '22',
@p3 nvarchar(20) = '33'
AS
Begin
print @p1
print @p2
print @p3
SELECT * FROM mytable
End


/* Store Procedure 呼叫方式 */


-- 1.不傳任何參數
exec pr_test

-- 2.只想改變第2個參數[這時,就需要透過 default 關鍵字來填不想改變的部份了]
exec pr_test default,'我是好人',default

-- 3.透過指定的方式
exec pr_test @p2='我是好人'

參考網址:
http://www.dotblogs.com.tw/ajun/archive/2008/04/01/2397.aspx

2008年6月4日 星期三

PageRequestManager

每一個使用 ASP.NET AJAX 的 .aspx 頁面都會放一個 ScriptManager 控制項。這控制項裡存放著控制 UpdatePanel 所需的 javascript 函式。不管是 ScriptManager 還是 UpdatePanel ,背後都還有一個老闆在監督著,這就是 PageRequestManager。

擔當非同步處理的 PageRequestManager,也是有所謂的生命週期。他共有5種:

Event 順序Event 說明
1. initializeRequestRaised before processing of the asynchronous request starts. You can use this event to cancel a postback.
2. beginRequestRaised before processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to set request headers or to begin an animation that indicates that the page is processing.
3. pageLoadingRaised after the response from the server to an asynchronous postback is received but before any content on the page is updated. You can use this event to provide a custom transition effect for updated content.
4. pageLoadedRaised after all content on the page is refreshed, as a result of either a synchronous or an asynchronous postback. You can use this event to provide a custom transition effect for updated content.
5. endRequestRaised after an asynchronous postback is finished and control has been returned to the browser. You can use this event to provide a notification to users or to log errors.



攔PageRequestManager5種生命週期的方法:

<script type="text/javascript">
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(initializeRequest);
prm.add_beginRequest(beginRequest);
prm.add_pageLoading(pageLoading);
prm.add_pageLoaded(pageLoaded);
prm.add_endRequest(endRequest);

function initializeRequest(sender, initializeRequestEventArgs)
{
alert('initialize function');
}

function beginRequest(sender, beginRequestEventArgs)
{
alert('beginRequest function');
}

function pageLoading(sender, pageLoadingEventArgs)
{
alert('pageLoading function');
}

function pageLoaded(sender, pageLoadedEventArgs)
{
alert('pageLoaded function');
}

function endRequest(sender, endRequestEventArgs)
{
alert('endRequest function');
}
</script>

[程式參考]