星期三, 3月 31, 2010

javascript keycode

Key Codes


This document is written by Helge Willum Larsen
It contains a list of all "onkeypress", "onkeydown" and "onkeyup" KeyCodes in JavaScript,
that can be typed with a DANISH KEYBOARD !!!
Other keyboards probably have other KeyCodes.

The first section is tested with the Microsoft Internet Explore 5.0 and the Netscape
Communicator 4.51. At this time, Netscape didn't support "onkeydown" and "onkeyup".

I strongly recommend that you use the "onkeypress" function.
It has the greatest browser-compatibility.
Otherwise, you can maybe use some of the codes in the bottom of the page:


____________________________________________________________________________________________

KeyCodes (ALL keyboards): onkeypress  Tested with Internet Explore 5.0
By: Helge Willum Larsen     and Netscape Communicator 4.51
       on a DANISH keyboard
____________________________________________________________________________________________

SUPPORTS MULTIPLE KEYPRESSES:
                       [A] = [a]
             [Shift] + [A] = [A]
          [CapsLock] + [A] = [A]
[Shift] + [CapsLock] + [A] = [a]

ALL KEYS THAT CREATES THE SAME OUTPUT, HAVE THE SAME KEYCODES !

[NumPad 1] is the same as [1] (if NumLock)
[NumPad +] is the same as [+]

DOES NOT SUPPORT ARROW-KEYS, DELETE, INSERT, SHIFT, ALT, CTRL, TAB, ESC...........!
But it supports [Return / Enter] and [Backspace]
____________________________________________________________________________________________


Button:   keyCode:

[BackSpace]    8

[Return / Enter]  13

[!]    33
["]    34
[#]    35
[$]    36
[%]    37
[&]    38
[']    39
[(]    40
[)]    41
[*]    42
[+]    43
[,]    44
[-]    45
[.]    46
[/]    47
[0]    48
[1]    49
[2]    50
[3]    51
[4]    52
[5]    53
[6]    54
[7]    55
[8]    56
[9]    57
[:]    58
[;]    59
[<]    60
[=]    61
[>]    62
[?]    63
[@]    64
[A]    65
[B]    66
[C]    67
[D]    68
[E]    69
[F]    70
[G]    71
[H]    72
[I]    73
[J]    74
[K]    75
[L]    76
[M]    77
[N]    78
[O]    79
[P]    80
[Q]    81
[R]    82
[S]    83
[T]    84
[U]    85
[V]    86
[W]    87
[X]    88
[Y]    89
[Z]    90
[[]    91
[\]    92
[]]    93
[^]    94
[_]    95
[`]    96
[a]    97
[b]    98
[c]    99
[d]   100
[e]   101
[f]   102
[g]   103
[h]   104
[i]   105
[j]   106
[k]   107
[l]   108
[m]   109
[n]   110
[o]   111
[p]   112
[q]   113
[r]   114
[s]   115
[t]   116
[u]   117
[v]   118
[w]   119
[x]   120
[y]   121
[z]   122
[{]   123
[|]   124
[}]   125
[~]   126

[£]   163
[¤]   164

[§]   167
[¨]   168

[´]   180

[½]   189

[Å]   197
[Æ]   198

[Ø]   216

[å]   229
[æ]   230

[ø]   248










____________________________________________________________________________________________

KeyCodes (DANISH keyboard): onkeydown / onkeyup Tested with Internet Explore 5.0)
By: Helge Willum Larsen
____________________________________________________________________________________________

DOES NOT SUPPORT MULTIPLE KEYPRESSES !

ALL KEYS HAVE THEIR OWN, INDIVIDUAL KEYCODE !

[NumPad 1] is NOT the same as [1]
[NumPad +] is NOT the same as [+]
____________________________________________________________________________________________


Button:   keyCode: NumLock: CapsLock: ScrollLock:

[BackSpace]    8  -  -  -
[Tab]     9  -  -  -

[NumPad 5]   12  no  -  -
[Return / Enter]  13  -  -  -

[Shift]    16  -  -  -
[Ctrl]    17  -  -  -
[Alt]    18  -  -  -
[Pause / Break]   19  -  -  -
[CapsLock]   20  -  -  -

[Esc]    27  -  -  -

[Space]    32  -  -  -
[Page Up]   33  -  -  -
[Page Down]   34  -  -  -
[End]    35  -  -  -
[Home]    36  -  -  -
[LeftArrow]   37  -  -  -
[UpArrow]   38  -  -  -
[RightArrow]   39  -  -  -
[DownArrow]   40  -  -  -

[PrintScreen / SysRq]  44  -  -  -
[Insert]   45  -  -  -
[Delete]   46  -  -  -

[0]    48  -  -  -
[1]    49  -  -  -
[2]    50  -  -  -
[3]    51  -  -  -
[4]    52  -  -  -
[5]    53  -  -  -
[6]    54  -  -  -
[7]    55  -  -  -
[8]    56  -  -  -
[9]    57  -  -  -

[A]    65  -  -  -
[B]    66  -  -  -
[C]    67  -  -  -
[D]    68  -  -  -
[E]    69  -  -  -
[F]    70  -  -  -
[G]    71  -  -  -
[H]    72  -  -  -
[I]    73  -  -  -
[J]    74  -  -  -
[K]    75  -  -  -
[L]    76  -  -  -
[M]    77  -  -  -
[N]    78  -  -  -
[O]    79  -  -  -
[P]    80  -  -  -
[Q]    81  -  -  -
[R]    82  -  -  -
[S]    83  -  -  -
[T]    84  -  -  -
[U]    85  -  -  -
[V]    86  -  -  -
[W]    87  -  -  -
[X]    88  -  -  -
[Y]    89  -  -  -
[Z]    90  -  -  -

[Turn Off] (special)  94  -  -  -
[Sleep] (special)  95  -  -  -
[NumPad 0]   96  yes  -  -
[NumPad 1]   97  yes  -  -
[NumPad 2]   98  yes  -  -
[NumPad 3]   99  yes  -  -
[NumPad 4]  100  yes  -  -
[NumPad 5]  101  yes  -  -
[NumPad 6]  102  yes  -  -
[NumPad 7]  103  yes  -  -
[NumPad 8]  104  yes  -  -
[NumPad 9]  105  yes  -  -
[NumPad *]  106  -  -  -
[NumPad +]  107  -  -  -
[NumPad -]  109  -  -  -
[NumPad ,]  110  -  -  -
[NumPad /]  111  -  -  -
[F1]   112  -  -  -
[F2]   113  -  -  -
[F3]   114  -  -  -
[F4]   115  -  -  -
[F5]   116  -  -  -
[F6]   117  -  -  -
[F7]   118  -  -  -
[F8]   119  -  -  -
[F9]   120  -  -  -
[F10]   121  -  -  -
[F11]   122  -  -  -
[F12]   123  -  -  -

[NumLock]  144  -  -  -
[ScrollLock]  145  -  -  -

[+] (next to [0]) 187  -  -  -
[,]   188  -  -  -
[-] (next to [.]) 189  -  -  -
[.]   190  -  -  -

[Æ]   192  -  -  -

[´] (next to [+]) 219  -  -  -
[½] (next to [1]) 220  -  -  -
[Å]   221  -  -  -
[Ø]   222  -  -  -

[<] (next to [Z]) 226  -  -  -

[Wake Up] (special) 255  -  -  -

____________________________________________________________________________________________





____________________________________________________________________________________________

Functions:      Tested with Internet Explore 5.0
By: Helge Willum Larsen     and Netscape Communicator 4.51
____________________________________________________________________________________________
Number:

 
String:

星期一, 3月 22, 2010

[Asp.Net] Datatable Using Group By

今天剛好有需求要將取得的datatable再做group by,資料有點不好找。
記錄一下以備往後需求:

星期日, 3月 21, 2010

sql 指定日期查詢

串接字串以達到指定查詢日期的效果

SELECT    * FROM         vw_CourseList
WHERE     (CourseStart BETWEEN CONVERT(datetime, STR(YEAR(GETDATE())) + '/03/01') AND CONVERT(datetime, STR(YEAR(DATEADD(year, 1, GETDATE())))
                      + '/02/28'))

[MS SQL] 日期處理方法

--檢查是否為SQL SERVER合法日期格式


SELECT ISDATE('2004-03-01')
--1 (int)正確
SELECT ISDATE('2004-02-33')
--0 (int)錯誤
--取得現在時間GETDATE()
select GETDATE()
--2008-04-26 03:25:31.900

ASP.NET Buttom postback前的檢查

常常需要用到按下按鈕前要提醒使用者是否繼續執行。
最普遍的做法
this.btnClosed.Attributes.Add("onclick", "return confirm('你確定嗎?');");

以下有佛心來的做法整理,使用XMLHttpRequest、doPostback 、Callback三種:
ASP.NET Postback前檢查的方式

ListView 自動編號

如題:跟datalist 自動編號的寫法差不多,
呼叫方法不一樣而已,記錄一下。
<asp:ListView ID="lvHwScore" runat="server">
<EmptyDataTemplate>無資料</EmptyDataTemplate>
<ItemTemplate>
<tr>
<td><%#Container.DataItemIndex + 1 %></td>
<td><%#this.ConvertHWScoreNull(Eval("HomeWorkAssignScore").ToString())%></td>
<td><%#Eval("MemberNo")%></td>
<td>
<a href="javascript:IframeParentNotify(<%#Eval("HomeWorkAssignParentID")%>,<%#Eval("HomeWorkAssignID")%>)">
<%#Eval("MemberName")%>
</a>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td><%#Container.DataItemIndex + 1 %></td>
<td><%#this.ConvertHWScoreNull(Eval("HomeWorkAssignScore").ToString())%></td>
<td><%#Eval("MemberNo")%></td>
<td>
<a href="javascript:IframeParentNotify(<%#Eval("HomeWorkAssignParentID")%>,<%#Eval("HomeWorkAssignID")%>)">
<%#Eval("MemberName")%>
</a>
</td>
</tr>
</AlternatingItemTemplate>
<LayoutTemplate>
<table>
<thead>
<td>排名</td>
<td>成績</td>
<td>學號</td>
<td>姓名</td>
</thead>
<tbody>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
</asp:ListView>

iframe中觸發原本父視窗的事件

今天剛好需要在原本視窗開一個 iframe,
然後iframe又需要執行click事件後,通知原本的視窗相關對應。
一看就知這種方法一定很多人遇到,所 以google一下就有解了。
請參考這篇藍色小舖 :iframe裡的事件可以傳遞到外面的母視窗嗎?

FireFox: 可以將事件傳給母視窗, 而母視窗的按鍵函數可以正確秀出來, 如下:
// 正確
// 子視窗裡
window.parent.MainKeyboardUp(event);

// 母視窗裡
function MainKeyboardUp(myEvent) {
  ...
  alert("myEvent.which");
  ...
}
IE: 不可以將事件傳給母視窗, 只能傳值, 然後在母視窗中去判別事件是否為 undefine
// 正確
// 子視窗裡
window.parent.MainKeyboardUp(event.keyCode); 

// 母視窗裡
function MainKeyboardUp(myEvent) { 
  if (myEvent) { // 有 define , myEvent是按鍵代碼, 用在子--->母
    alert("myEvent");
  ...
  } else { // undefine, 用在母視窗自身的按鍵行為
    if (document.all) {
      myEvent = event;
    }
    var keycodevalue = myEvent.keyCode;
  }
  ...
}

星期四, 3月 18, 2010

Google Char Sample Code Using Javascript


<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages: ["columnchart"]});
</script>
<script type="text/javascript">
function drawVisualization() {
var data = new google.visualization.DataTable();

// 設定X軸和Y軸
data.addColumn("string", "Name");
data.addColumn("number", "股價");

// 設定欄位數量
data.addRows(4);

// 設定X軸欄位名稱
data.setCell(0, 0, "中美晶");
data.setCell(1, 0, "合晶");
data.setCell(2, 0, "綠能");
data.setCell(3, 0, "德淵");

// 設定Y軸欄位值
data.setCell(0, 1, 68.0);
data.setCell(1, 1, 41.9);
data.setCell(2, 1, 98.7);
data.setCell(3, 1, 10.95);

// 建立ColumnChart圖表
new google.visualization.ColumnChart(document.getElementById("visualization")).
draw(data, null);
}

google.setOnLoadCallback(drawVisualization);
</script>

<!-- 圖表顯示位置及大小 -->
<div id="visualization" style="width: 400px; height: 300px;"></div>

星期二, 3月 16, 2010

匯入文件太大時,匯入工具無法支援

select * into [test]
from OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 5.0;HDR=YES;DATABASE=c:\xxx.xls',importdata$)

星期三, 3月 10, 2010

Update From Query

UPDATE    Art.dbo.Course
SET              Art.dbo.Course.CourseStart = Shanghai.dbo.Course.BeginDate
from Art.dbo.Course,Shanghai.dbo.Course
WHERE     (Art.dbo.Course.CourseID =  Shanghai.dbo.Course.CourseID)

UPDATE   Members
SET             MemberProfessional = Professional
from Members,TeacherProfessional
WHERE     (MemberNo = No)

同以下語法
UPDATE    Members
SET              MemberProfessional = TeacherProfessional.Professional
FROM         Members INNER JOIN
                      TeacherProfessional ON Members.MemberNo = TeacherProfessional.No

Reference:
http://blog.yam.com/masonblog/article/11536008
Update from a Select
update 问题,更新 表一的A字段 = 表二的B字段

星期日, 3月 07, 2010

[MS SQL]Sql object explorer error

最近要停止SQL都會發生拒絕存取(object explorer),只能先暫用Config Manageer來停止了。


口碑行銷與置入性行銷的異同

其實之前我寫過一篇「談置入性行銷對口碑的影響」,其中我分享過對於置入性行銷的觀點,並且提出我認為成功的置入性行銷模式。最近,我在後端發現,有很多人使用「置入性行銷」這個關鍵字搜尋、瀏覽buzz lab的文章,加上也有一些朋友問過我該怎麼看口碑行銷與置入行銷,所以我決定利用今天的文章來好好整理我的看法。

在談口碑行銷時,我是從一些誤解口碑行銷的現象開始論述,我想同樣的,也從一些對置入性行銷的誤解開始談起。我想,置入性行銷應該是最近幾年被「污名化」最嚴重的幾個行銷策略之ㄧ,關於這個情況,我的假設是可能跟一些政治人物運用這個名詞來包裝選戰策略有關(我可以說每一場選舉到最後都會被發現是一場騙局嗎?啊,我說出來了…)。除此之外,廣告界運用置入行銷也有許多濫用的現象,例如我在「談置入性行銷對口碑的影響」一文中所提到的觀察,這些都使得置入性行銷不僅不被消費者接受,甚至也使得知道該如何正確運用置入性行銷的行銷人不敢使用這個名詞來定義他們的策略,最後,這些行銷人便轉而用「口碑行銷」來定義他們的提案,這使得這兩個本質上不同的策略方向,似乎被硬扯上了關係。


不過,雖然口碑行銷與置入性行銷有本質上的差異,但是並不代表它們之間沒有一些可以搭配運用的地方。最近,adidas公司為了行銷其下的幾款籃球鞋,拍了好幾段NBA明星球員跟年輕小球員一起練球、教球的影片,不僅在網路上供大家自由下載,也在每一家專賣店的大型液晶上播放。在這幾段影片中,沒有一段內容討論球鞋的功能或優點,每一段都在表現籃球的基本精神,例如:團隊合作的重要,自我實現的重要…等。假設這廣告影片是一個NBA的例行性節目,事先不告訴觀眾這是誰出資拍攝的,我想這是一個口碑行銷與置入性行銷的完美結合。為什麼呢?因為節目本身是有意義的,它讓觀賞者有得到觀看一個好節目應該得到的益處,而裡面刻意安排的商品,其實也不會讓這些球星與小球員們「用起來非常不自然」。當然,認同這些球員所說出的道理的觀眾也很難不去注意這些球員的動作,而這些動作中,無形中就置入了商品的概念。再次歸類一下幾個重點,在這樣的撘配之下,結構要素是:跟商品不直接相關但擁有獨立價值的置入體、以自然合理的方式置入商品、以商品應該用有的口碑在置入體表現出來、具有話題性並且便利的分享機制。

講完可以搭配運用的部份,接著開始來討論不同點。由於行銷本身想要創造的價值是相同的,就好像賽場上的終點一樣,所以每個運動員雖會有一些相同的動作,但最後決勝的關鍵往往是那些不同之處。正確的置入性行銷,原則上,是一個吸引目光而又不想引起排斥感的策略,它的價值在於讓消費者自然的接受商品與品牌,並在無形之中定位它們的價值,這可以讓消費者在購入商品之前,先想起所行銷的品牌與商品,增加消費者購入的機會。而口碑行銷也含有以上的目的,不過它更重視的是消費者針對需求面的觀感,也就是實際上創造體驗所得到的口碑傳遞。口碑行銷通常是一個具有長遠影響的概念,畢竟要推動消費者持續傳遞口碑的力道,不能只是一時的引起注意。

最後,還是那句老話,各個行銷策略都有其長處也有其短處,本身無所謂好壞,行銷人本身的素質、經驗與觀念才是決定策略是否成功的關鍵。

Posted by REX http://mmdays.com/2007/12/07/difference/

星期一, 3月 01, 2010

C# 設定系統時間



[StructLayout(LayoutKind.Sequential)]
public struct SystemTime
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMiliseconds;
}
public class SetSystemDateTime
{
[DllImport("Kernel32.dll")]
public static extern bool SetLocalTime(ref SystemTime sysTime);

public static bool SetLocalTimeByStr(string timestr)
{
bool flag = false;
SystemTime sysTime = new SystemTime();
DateTime dt = Convert.ToDateTime(timestr);
sysTime.wYear = Convert.ToUInt16(dt.Year);
sysTime.wMonth = Convert.ToUInt16(dt.Month);
sysTime.wDay = Convert.ToUInt16(dt.Day);
sysTime.wHour = Convert.ToUInt16(dt.Hour);
sysTime.wMinute = Convert.ToUInt16(dt.Minute);
sysTime.wSecond = Convert.ToUInt16(dt.Second);
try
{
flag = SetSystemDateTime.SetLocalTime(ref sysTime);
}
catch (Exception e)
{
Console.WriteLine("SetSystemDateTime函数执行异常" + e.Message);
}
return flag;
}
}