台灣國際品牌價值歷年榜單
品牌計畫每年與國際知名的品牌鑑價單位 Interbrand 合作,公布當年度台灣20大國際品牌榜單。
2015年1月5日 星期一
2013年3月21日 星期四
Google停止Reader服務後的取代方案
依個人喜好順序
喜歡他的介面,但是偶而會斷線
匯入資料方便
有多種顯示模式
FireFox的plug-in
Chrome版與手機版
方便匯入
多種檢視模式:
Titles Only - Google Reader
Magazine
Mosaic
Cards
Full Articles有INDEX的功能,還不錯
ASP.NET 遇到IE10
新上線的IE10,在執行ASP.NET的程式時,會遇到一些問題,目前已知的有:
要解決這些問題,有幾個方法:
註: 安裝更新時,可選擇暫時不重新開機,但是會重新啟動網站,因此會斷線數十秒鐘
參考資料: http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx
- Gridview 的換頁問題
- Auto Postback
- AJAX的執行
要解決這些問題,有幾個方法:
- 鴕鳥法: 較USER開啟相容模式即可
- By 每個site解決
- .NET 4 Browser Update NuGet Package - http://nuget.org/List/Packages/App_BrowsersUpdate
- install-package App_BrowsersUpdate
- .NET 2.0 Browser Update NuGet Package - http://nuget.org/List/Packages/App_BrowsersUpdate.net20
- install-package App_BrowsersUpdate.net20
- Note that NuGet is VS2010 specific so if you don't have nuget.exe and .NET 4, you can also copy the .NET 2 updated browser files into ~\App_Browsers manually from this zip file.
- By 每個Server解決
- .NET 4 - http://support.microsoft.com/kb/2600088
- .NET 2.0
- http://support.microsoft.com/kb/2600100 for Win7 SP1/Windows Server 2008 R2 SP1, Windows Vista/Server 2008, Windows XP/Server 2003
- http://support.microsoft.com/kb/2608565 for Win7/Windows Server 2008 R2 RTM
註: 安裝更新時,可選擇暫時不重新開機,但是會重新啟動網站,因此會斷線數十秒鐘
參考資料: http://www.hanselman.com/blog/BugAndFixASPNETFailsToDetectIE10CausingDoPostBackIsUndefinedJavaScriptErrorOrMaintainFF5ScrollbarPosition.aspx
2012年5月25日 星期五
Google 发布了 Google Webmaster Academy
Google 发布了 Google Webmaster Academy:

Google发布了Google Webmaster Academy,这个专门面向站长的学习站点
其中包含了下面这些内容:
如果你是初次运行一个网站,看看这部分的内容会帮助你了解搜索。
另外,今天看到的消息,Google并购了摩托罗拉手机部门,摩托罗拉是最早生产手机的公司,专利无数啊。Google会如何利用它们的技术呢?等着看。
把网站放在Dreamhost,通过LinkWorth获取广告收益,每个链接高达$40。

Google发布了Google Webmaster Academy,这个专门面向站长的学习站点
其中包含了下面这些内容:
- Google如何运行的,搜索算法,广告内容
- 让Google了解你的网站
- 影响你的网站在Google搜索上的表现
- 创建最棒的内容
- 图片和视频搜索
- 利用Google的社交工具
如果你是初次运行一个网站,看看这部分的内容会帮助你了解搜索。
另外,今天看到的消息,Google并购了摩托罗拉手机部门,摩托罗拉是最早生产手机的公司,专利无数啊。Google会如何利用它们的技术呢?等着看。
把网站放在Dreamhost,通过LinkWorth获取广告收益,每个链接高达$40。
延伸阅读
- 中文的Googleguy出现了
- 最近关于Google的几个话题
- 删除包含在Google索引中的网页或图片
- Yahoo Site Explorer关闭
- Google PageRank查询地址改变
- Google+ 社交网站
- 结果:投诉采集本站的那些站点
- 投诉采集本站的那些站点
- 借Google反垃圾的东风
- Google PageRank 终于更新了
Google Currents 潮流同步 – 製作專屬自己的數位內容刊物
Google Currents 潮流同步 – 製作專屬自己的數位內容刊物: Google Currents 是Google的一項數位內容新服務,中文名稱叫「Google 潮流同步」,名稱很真的很潮,不過從字面上實在是難以去了解到底是什麼玩意?說穿了它是一個數位內容發行以及開放訂閱的平台,專門針對行動裝置設計的服務,內容提供者可以透過這項服務產生專屬於自己的數位內容刊物,可以匯入網站的RSS也可以自行撰寫。
...詳全文(共1157字)
...詳全文(共1157字)
2010年12月20日 星期一
2010年12月16日 星期四
2010年12月15日 星期三
[技術筆記] 在windows server 2008的工作排程中執行IE開啟網頁
源起
在開發網路程式(ASP、ASP.NET...等)時,有些功能必須重複執行,通常會使用排程來設定這樣的工作。
但是如果程式設計師只有網路程式的經驗,不會寫WIN-FORM程式,好像也沒關係,寫成WEB版再設定以IE開啟即可。
以前的解決方案
指令如下:
"C:\Program Files\Internet Explorer\iexplore.exe" "http://url/?par1=value"
注意:因為路徑有空白,因此要加上"",否則會有找不到程式的錯誤
將指令設定到『工作排程』中執行即可完成此項任務。
問題點
但是這樣的解決方案看似容易,確有幾個問題:
1. IE是CLIENT端程式,必須在登入狀況下才能執行
2. IE會自動開啟,但是不會自動結束
3. IE是個大程式,佔用很多資源
2、3還好解決,用『工作排程』可以結束執行中的IE
1可以用自動登入來解決
最佳解決方案
最近SERVER換成Windows Server 2008,重新思考這個問題,希望能有較好的解決方案。
網路找了一下,發現有人用VBS來取代IE,是個不錯的方法,VBS程式碼列表如下:
主要原理是建立一個Microsoft.XMLHTTP object來取代IE
執行VBS: cscript xxx.vbs
執行時會開啟一個DOS CMD,執行完自動結束,比開啟IE快10倍
如此一來,一次解決以上三個問題,太帥了
在開發網路程式(ASP、ASP.NET...等)時,有些功能必須重複執行,通常會使用排程來設定這樣的工作。
但是如果程式設計師只有網路程式的經驗,不會寫WIN-FORM程式,好像也沒關係,寫成WEB版再設定以IE開啟即可。
以前的解決方案
指令如下:
"C:\Program Files\Internet Explorer\iexplore.exe" "http://url/?par1=value"
注意:因為路徑有空白,因此要加上"",否則會有找不到程式的錯誤
將指令設定到『工作排程』中執行即可完成此項任務。
問題點
但是這樣的解決方案看似容易,確有幾個問題:
1. IE是CLIENT端程式,必須在登入狀況下才能執行
2. IE會自動開啟,但是不會自動結束
3. IE是個大程式,佔用很多資源
2、3還好解決,用『工作排程』可以結束執行中的IE
1可以用自動登入來解決
最佳解決方案
最近SERVER換成Windows Server 2008,重新思考這個問題,希望能有較好的解決方案。
網路找了一下,發現有人用VBS來取代IE,是個不錯的方法,VBS程式碼列表如下:
Call OpenURL()
Sub OpenURL()
'Force the script to finish on an error.
On Error Resume Next
'Declare variables
Dim objRequest
Dim URL
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Put together the URL link appending the Variables.
URL = "http://url?par1=value"
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URL , false
'Send the HTML Request
objRequest.Send
'Set the object to nothing
Set objRequest = Nothing
End Sub
主要原理是建立一個Microsoft.XMLHTTP object來取代IE
執行VBS: cscript xxx.vbs
執行時會開啟一個DOS CMD,執行完自動結束,比開啟IE快10倍
如此一來,一次解決以上三個問題,太帥了
2010年12月6日 星期一
[技術筆記] ASP.NET 內建event執行順序
在ASP.NET程式中,提供許多內建的EVENT,可以用來處理一些功能,如果只有單獨一個PAGE,就比較單純。但是當導入Master Page以及User Control後,通常讓程式設計師無所適從,在此整理相關訊息:
單獨一個PAGE的狀況:
1. PreInit
2. Init
3. PreLoad
4. Load
5. Load Complete
6. PreRender
7. PreRender Complete
8. Unload
考慮比較複雜的狀況:
有Content page、Master page以及User Control(包括Content page controls及Master page controls)
1.Content page PreInit event.
2.Master page controls Init event.
3.Content page controls Init event.
4.Master page Init event.
5.Content page Init event.
6.Content page Load event.
7.Master page Load event.
8.Master page controls Load event.
9.Content page controls Load event.
10.Content page PreRender event.
11.Master page PreRender event.
12.Master page controls PreRender event.
13.Content page controls PreRender event.
14.Master page controls Unload event.
15.Content page controls Unload event.
16.Master page Unload event.
17.Content page Unload event.
Microsoft提供下圖做為參考(但是不含MasterPage)
單獨一個PAGE的狀況:
1. PreInit
2. Init
3. PreLoad
4. Load
5. Load Complete
6. PreRender
7. PreRender Complete
8. Unload
考慮比較複雜的狀況:
有Content page、Master page以及User Control(包括Content page controls及Master page controls)
1.Content page PreInit event.
2.Master page controls Init event.
3.Content page controls Init event.
4.Master page Init event.
5.Content page Init event.
6.Content page Load event.
7.Master page Load event.
8.Master page controls Load event.
9.Content page controls Load event.
10.Content page PreRender event.
11.Master page PreRender event.
12.Master page controls PreRender event.
13.Content page controls PreRender event.
14.Master page controls Unload event.
15.Content page controls Unload event.
16.Master page Unload event.
17.Content page Unload event.
Microsoft提供下圖做為參考(但是不含MasterPage)
2010年10月19日 星期二
[技術通報] KB2360131更新會造成網站顯示不正常
微軟於2010/10/14發佈的IE KB2360131更新,防止了跨SITE的CSS參考(cross site css),如果網頁中有跨SITE的CSS參考,IE將不會套用該CSS,因此會造成顯示不正確(該有的字、圖都會出現,但是排版不正確)
KB2360131更新主要防止在CSS中的URL屬性(例如background-image),會被導入不安全的頁面或是程式,因此加上此防護。請參考以下網址的SAMPLE:
http://ajaxian.com/archives/xsstc-cross-site-scripting-through-css-data
如何修改網頁以避免不正常:
簡單來說就是拿掉跨SITE的CSS參考
1. 將其他SITE的CSS複製一份至本機,然後修改CSS參考URL至本機
2. IIS中設定跨SITE路徑參考至原來的CSS位置,同樣修改CSS參考URL至本機的路徑
方法一較簡單,但是壞處是要維護兩套CSS
方法二較複雜,也可能無法做到,但是好處是不需要維護兩套CSS
以上給大家參考
KB2360131更新主要防止在CSS中的URL屬性(例如background-image),會被導入不安全的頁面或是程式,因此加上此防護。請參考以下網址的SAMPLE:
http://ajaxian.com/archives/xsstc-cross-site-scripting-through-css-data
如何修改網頁以避免不正常:
簡單來說就是拿掉跨SITE的CSS參考
1. 將其他SITE的CSS複製一份至本機,然後修改CSS參考URL至本機
2. IIS中設定跨SITE路徑參考至原來的CSS位置,同樣修改CSS參考URL至本機的路徑
方法一較簡單,但是壞處是要維護兩套CSS
方法二較複雜,也可能無法做到,但是好處是不需要維護兩套CSS
以上給大家參考
2010年2月25日 星期四
Visual Studio 連線至遠端WEB網站的方法
預先作業:
- 遠端SERVER要安裝FrontPage Server Extensions
- 控制台-->新增移除程式
- 新增WINDOWS元件
- Application Server-->IIS-->FrontPage 2002 Server Extensions
- 站台要配置FrontPage Server Extensions
- 至IIS
- 點選站台-->右鍵-->所有工作-->配置FrontPage Server Extensions
- 執行Visual Studio
- 選擇開啟網站
- 選擇遠端站台
- 輸入網址即可
2009年11月5日 星期四
客製化MOSS ALERT的EMAIL內容
I am trying to customize the alert notifications for a task list. I got to remove the “Description” field content and the “Title” field content from the email notifications that is being sent when a task is changed or assigned to somebody. I did the following steps for accomplishing the same:
1. I took a copy of the alerttemplates.xml and copied c:\temp folder in the server.
2. I added the field name “Description” in both the tags “ImmediateNotificationExcludedFields” and “DigestNotificationExcludedFields” under the SPAlertTemplateType.Tasks.
ID;Author;Title;Description;Editor;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;
ID;Author;Title;Description;Editor;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;
3. I did the above changes, saved the file, did an IISRESET and ran the command updatealerttemplates command using STSADM.exe.
4. I changed an item in a task and saved it.
5. The email that I received was not having the title in it, but the content in the “Description” field is still appearing and I need to exclude the same from the email notifications.
I tried this quite a number of times, but no luck. I am still seeing the Description field content in the email notifications that I receive.
I searched for all the possible options but could not get any beak through in this. If possible, I would like to help me out with this and also let me know, if there is any constraints in implementing this. Thanks in advance.
1. I took a copy of the alerttemplates.xml and copied c:\temp folder in the server.
2. I added the field name “Description” in both the tags “ImmediateNotificationExcludedFields” and “DigestNotificationExcludedFields” under the SPAlertTemplateType.Tasks.
ID;Author;Title;Description;Editor;Modified_x0020_By;Created_x0020_By;_UIVersionString;ContentType;TaskGroup;IsCurrent;Attachments;NumComments;
3. I did the above changes, saved the file, did an IISRESET and ran the command updatealerttemplates command using STSADM.exe.
4. I changed an item in a task and saved it.
5. The email that I received was not having the title in it, but the content in the “Description” field is still appearing and I need to exclude the same from the email notifications.
I tried this quite a number of times, but no luck. I am still seeing the Description field content in the email notifications that I receive.
I searched for all the possible options but could not get any beak through in this. If possible, I would like to help me out with this and also let me know, if there is any constraints in implementing this. Thanks in advance.
Sharepoint Server 2007(MOSS) Alert Email Troubleshoting--Part II
其他詳細步驟
1. Open the command window, go to the BIN folder and get the property of
Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url-pn
alerts-enabled
The expected output is
2. Open the MOSS Central Administration page, click Operations--Timer Job Status,
make sure the following two jobs are showing "success" and 100%
Change Log
Immediate Alerts
3. Make sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Restart the timer service if required.
4. 檢查資料庫:
在content db中,timerlock
Open SQL Query Analyzer, connect to the content database of problematic site.
Run the following query and copy the result out.
Select * from timerlock
Let me know the server name seen in the LockedBy column is the same one of this SPS
server. This server is responsible for processing the timer service.
1. Run the following query against the content database of problematic site
select * from eventcache where EventData is not null
(找出尚未送出的ALERT,若完成寄送,EventData 會被設為null)
This will out put all fo the subscritions which have not been processed yet. We can see if there are some alerts which are not processed
2. select * from eventlog where ListID = 'xxx'
()
You can get the ListID from the EventCache table by running
Select * from EventCache and check the documents which correspond to the problematic list.
3. If you cannot find any record in the step 1, please perform the following tests:
Put filemon on the SPS server and we can see if the Timer service picks up the alert template during the whole process.
a. Upload a new document to the document library which is supposed to have the alerts. Begin running the filemon.
b. Run
select * from eventcache order by EventTime DESC
Check if the latest log is the one corresponds to your uploaded document. Make sure the EventData and ACL columns are not NULL.
c. After 5 minutes or more minutes, check the EventCache table again to see if the EventData and ACL columns are NULLed.
d. If so, stop filemon after the EventData and ACL columns are NULLed
1. Open the command window, go to the BIN folder and get the property of
Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url
alerts-enabled
The expected output is
2. Open the MOSS Central Administration page, click Operations--Timer Job Status,
make sure the following two jobs are showing "success" and 100%
Change Log
Immediate Alerts
3. Make sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Restart the timer service if required.
4. 檢查資料庫:
在content db中,timerlock
Open SQL Query Analyzer, connect to the content database of problematic site.
Run the following query and copy the result out.
Select * from timerlock
Let me know the server name seen in the LockedBy column is the same one of this SPS
server. This server is responsible for processing the timer service.
1. Run the following query against the content database of problematic site
select * from eventcache where EventData is not null
(找出尚未送出的ALERT,若完成寄送,EventData 會被設為null)
This will out put all fo the subscritions which have not been processed yet. We can see if there are some alerts which are not processed
2. select * from eventlog where ListID = 'xxx'
()
You can get the ListID from the EventCache table by running
Select * from EventCache and check the documents which correspond to the problematic list.
3. If you cannot find any record in the step 1, please perform the following tests:
Put filemon on the SPS server and we can see if the Timer service picks up the alert template during the whole process.
a. Upload a new document to the document library which is supposed to have the alerts. Begin running the filemon.
b. Run
select * from eventcache order by EventTime DESC
Check if the latest log is the one corresponds to your uploaded document. Make sure the EventData and ACL columns are not NULL.
c. After 5 minutes or more minutes, check the EventCache table again to see if the EventData and ACL columns are NULLed.
d. If so, stop filemon after the EventData and ACL columns are NULLed
Sharepoint Server 2007(MOSS) Alert Email Troubleshoting
0. 先檢查/解決MOSS本身傳送EMAIL的設定
至MOSS管理中心 > 作業 > 外寄電子郵件設定 設定相關資料
測試: 先找一個文件庫或清單,新增一個ALERT,若能收到設定完成的通知信,表示MOSS本身傳送EMAIL設定OK
以下針對當異動/新增發生時,無法收到ALERT EMAIL的狀況:
1. 先察看Timer Job的設定,因為ALERT是Timer Job來負責發送的,Timer Job是以SERVICE方式執行(Windows Sharepoint Service Timer)
先檢查SERVICE是否啟動
Made sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Then we restarted the timer service.
2. 並檢查JOB的執行狀況:
Opened the MOSS Central Administration page, clicked on Operations--Timer Job Status, made sure the following two jobs were showing "success" and 100%:
Change Log
Immediate Alerts
3. 再檢查設定:
Opened the command window, navigated to the BIN folder and got the property of Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url-pn alerts-enabled
The expected output is
4. 檢查content db的內容(參考以下的詳細步驟)
We found EventData and ACL are not NULL for the specific content database. This seems to be the key to the problem.
5. We checked the property job-immediate-alerts schedule
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url <http://server/> -pn
job-immediate-alerts
it showed Property Exist="No" for that specific site.
6. We used the following command to re-set the schedule
stsadm.exe -o setproperty -url-pn job-immediate-alerts -pv
"every 5 minutes between 0 and 59"
Alerts began to work.
如果發現有未執行的JOB,但是設定都正常,則需要重啟TIMER SERVICE,若是重啟失敗,則只有RESET SERVER了。
至MOSS管理中心 > 作業 > 外寄電子郵件設定 設定相關資料
測試: 先找一個文件庫或清單,新增一個ALERT,若能收到設定完成的通知信,表示MOSS本身傳送EMAIL設定OK
以下針對當異動/新增發生時,無法收到ALERT EMAIL的狀況:
1. 先察看Timer Job的設定,因為ALERT是Timer Job來負責發送的,Timer Job是以SERVICE方式執行(Windows Sharepoint Service Timer)
先檢查SERVICE是否啟動
Made sure the account running the SharePoint Timer service is the account which has the administrator Full Control permission over the site and the full permission over the content database. Then we restarted the timer service.
2. 並檢查JOB的執行狀況:
Opened the MOSS Central Administration page, clicked on Operations--Timer Job Status, made sure the following two jobs were showing "success" and 100%:
Change Log
Immediate Alerts
3. 再檢查設定:
Opened the command window, navigated to the BIN folder and got the property of Alerts-enabled to make sure the alerts are enabled for the timer service:
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url
The expected output is
4. 檢查content db的內容(參考以下的詳細步驟)
We found EventData and ACL are not NULL for the specific content database. This seems to be the key to the problem.
5. We checked the property job-immediate-alerts schedule
C:\Program Files\Common Files\Microsoft Shared\web server
extensions\12\BIN>stsadm.exe -o getproperty -url <http://server/> -pn
job-immediate-alerts
it showed Property Exist="No" for that specific site.
6. We used the following command to re-set the schedule
stsadm.exe -o setproperty -url
"every 5 minutes between 0 and 59"
Alerts began to work.
如果發現有未執行的JOB,但是設定都正常,則需要重啟TIMER SERVICE,若是重啟失敗,則只有RESET SERVER了。
2009年10月29日 星期四
How to Query SQL Database with a MOSS 2007 WebPart
There are a lot of articles out there that will show you how to create a basic WebPart in MOSS 2007 but I haven't yet seen one that will show you how to really do anything with that WebPart. I wanted to create a simple walk-through that will at least give you the foundation that you need to create a WebPart with some controls and connect to a SQL Database to retrieve some data and add it to a list.
As many of you have undoubtedly figured out by now, there is no way to visually design a WebPart in Visual Studio. For those of you who have written custom controls we would use the same technique to programmatically add the controls to the page at run time. In this example I will create WebPart that consists of a Button used to refresh that data in a SharePoint List and a Label to display a message to the user. The purpose of this WebPart is to populate a SharePoint list with items that are running low in our inventory.
Step 1: Creating the U.I.
In order to create the UI of our WebPart we have to add our controls to the page at run time. This is done by Overriding the CreateChildControls method of the WebPart class. You then use the Controls.Add() method to add new controls to the page. You also need to create the Event Handlers. The resulting code would look like this.
protected override void CreateChildControls()
{
Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl("
"));
base.CreateChildControls();
}
Step 2. Adding Connectin String to Web.Config
Next we need to set up a connection to our database. This of course means we need a web.config file to add our connection string to. Open the web.config file located in the virtual directory of your website. I recommend you make a back up of this first just in case. The file will be located at: C:\Inetpub\wwwroot\wss\VirtualDirectories\. -NOTE- this may be a port number.
To add your connection string to the web.config you first need to add the proper section to the config file. Scroll all the way to the bottom of your config file and you will see the following line: . Just after this line, and before the line, add the following section with your connection string. Save and close.
Now you are ready to build your Data access class.
Step 3. Creating the Data Access class
I created a new class called ListManager and added functionality to handle the retrieval of data from the database and us it to update the SharePoint list. In the constructor of the class I added the following code to set the connection string.
public ListManager()
{
System.Configuration.AppSettingsReader rdr = new AppSettingsReader();
connStr = ConfigurationManager.ConnectionStrings["DBConn"].ToString();
}
I created a method to get the out of stock items form the database just like we would in any other .NET application. The code looks like this:
private void GetOutOfStockItemsDataSet()
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connStr);
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_SelectOutOfStockItems";
SqlDataAdapter da = new SqlDataAdapter(cmd);
try
{
da.Fill(ds);
}
finally
{
da.Dispose();
}
}
Now we just want to iterate through the items in the DataSet adding the new items and delete the old ones from the list as needed
As many of you have undoubtedly figured out by now, there is no way to visually design a WebPart in Visual Studio. For those of you who have written custom controls we would use the same technique to programmatically add the controls to the page at run time. In this example I will create WebPart that consists of a Button used to refresh that data in a SharePoint List and a Label to display a message to the user. The purpose of this WebPart is to populate a SharePoint list with items that are running low in our inventory.
Step 1: Creating the U.I.
In order to create the UI of our WebPart we have to add our controls to the page at run time. This is done by Overriding the CreateChildControls method of the WebPart class. You then use the Controls.Add() method to add new controls to the page. You also need to create the Event Handlers. The resulting code would look like this.
protected override void CreateChildControls()
{
Controls.Add(new LiteralControl("
| ")); cmdRefresh = new Button(); cmdRefresh.ID = "cmdRefresh"; cmdRefresh.Text = "Refresh"; cmdRefresh.ToolTip = "Click here to refresh Out of Stock Items."; this.cmdRefresh.Click += new EventHandler(cmdRefresh_Click); Controls.Add(cmdRefresh); Controls.Add(new LiteralControl(" | ")); Controls.Add(new LiteralControl("
| ")); txtMessage = new Label(); txtMessage.ID = "txtMessage"; txtMessage.Visible = true; txtMessage.ForeColor = System.Drawing.Color.Red; Controls.Add(txtMessage); Controls.Add(new LiteralControl(" | ")); Controls.Add(new LiteralControl("
base.CreateChildControls();
}
Step 2. Adding Connectin String to Web.Config
Next we need to set up a connection to our database. This of course means we need a web.config file to add our connection string to. Open the web.config file located in the virtual directory of your website. I recommend you make a back up of this first just in case. The file will be located at: C:\Inetpub\wwwroot\wss\VirtualDirectories\
To add your connection string to the web.config you first need to add the proper section to the config file. Scroll all the way to the bottom of your config file and you will see the following line: . Just after this line, and before the line, add the following section with your connection string. Save and close.
Now you are ready to build your Data access class.
Step 3. Creating the Data Access class
I created a new class called ListManager and added functionality to handle the retrieval of data from the database and us it to update the SharePoint list. In the constructor of the class I added the following code to set the connection string.
public ListManager()
{
System.Configuration.AppSettingsReader rdr = new AppSettingsReader();
connStr = ConfigurationManager.ConnectionStrings["DBConn"].ToString();
}
I created a method to get the out of stock items form the database just like we would in any other .NET application. The code looks like this:
private void GetOutOfStockItemsDataSet()
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connStr);
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "usp_SelectOutOfStockItems";
SqlDataAdapter da = new SqlDataAdapter(cmd);
try
{
da.Fill(ds);
}
finally
{
da.Dispose();
}
}
Now we just want to iterate through the items in the DataSet adding the new items and delete the old ones from the list as needed
2009年10月13日 星期二
2009年9月29日 星期二
2009年8月12日 星期三
未來五年內developers要學的10大技能
1: One of the “Big Three” (.NET, Java, PHP)
(主流程式開發)
Unless there is a radical shift in the development world (akin to an asteroid hitting Redmond), most developers will need to know at least one of the Big Three development systems — .NET (VB.NET or C#), Java, or PHP — for the near future. It’s not enough to know the core languages, either. As projects encompass more and more disparate functionality, you’ll need to know the associated frameworks and libraries more deeply.
2: Rich Internet Applications (RIAs)
(豐富內涵的網路應用程式)
Love it or hate it, in the last few years, Flash is suddenly being used for more than just animations of politicians singing goofy songs. Flash has also sprouted additional functionality in the form or Flex and AIR. Flash’s competitors, such as JavaFx and Silverlight, are also upping the ante on features and performance. To make things even more complicated, HTML 5 is incorporating all sorts of RIA functionality, including database connectivity, and putting the formal W3C stamp on AJAX. In the near future, being an RIA pro will be a key resume differentiator.
3: Web development
(Web程式開發)
Web development is not going away anytime soon. Many developers have been content to lay back and ignore the Web or to just stick to “the basics” their framework provides them with. But companies have been demanding more and more who really know how to work with the underlying technology at a “hand code” level. So bone up on JavaScript, CSS, and HTML to succeed over the next five years.
4: Web services
( Web服務)
REST or SOAP? JSON or XML? While the choices and the answers depend on the project, it’s getting increasingly difficult to be a developer (even one not writing Web applications) without consuming or creating a Web service. Even areas that used to be ODBC, COM, or RPC domains are now being transitioned to Web services of some variety. Developers who can’t work with Web services will find themselves relegated to legacy and maintenance roles.
5: Soft skills
(溝通協調技巧)
One trend that has been going for quite some time is the increasing visibility of IT within and outside the enterprise. Developers are being brought into more and more non-development meetings and processes to provide feedback. For example, the CFO can’t change the accounting rules without working with IT to update the systems. And an operations manager can’t change a call center process without IT updating the CRM workflow. Likewise, customers often need to work directly with the development teams to make sure that their needs are met. Will every developer need to go to Toastmasters or study How to Win Friends and Influence People? No. But the developers who do will be much more valuable to their employers — and highly sought after in the job market.
6: One dynamic and/or functional programming language
(至少一種dynamic and/or functional 程式語言)
Languages like Ruby, Python, F#, and Groovy still aren’t quite mainstream – but the ideas in them are. For example, the LINQ system in Microsoft’s .NET is a direct descendent of functional programming techniques. Both Ruby and Python are becoming hot in some sectors, thanks to the Rails framework and Silverlight, respectively. Learning one of these languages won’t just improve your resume, though; it will expand your horizons. Every top-flight developer I’ve met recommends learning at least one dynamic or functional programming language to learn new ways of thinking, and from personal experience, I can tell you that it works.
7: Agile methodologies
(敏捷的作業方式)
When Agile first hit mainstream awareness, I was a skeptic, along with many other folks I know. It seemed to be some sort of knee-jerk reaction to tradition, throwing away the controls and standards in favor of anarchy. But as time went on, the ideas behind Agile became both better defined and better expressed. Many shops are either adopting Agile or running proof-of-concept experiments with Agile. While Agile is not the ultimate panacea for project failure, it does indeed have a place on many projects. Developers with a proven track record of understanding and succeeding in Agile environments will be in increasingly high demand over the next few years.
8: Domain knowledge
(專業領域知識)
Hand-in-hand with Agile methodologies, development teams are increasingly being viewed as partners in the definition of projects. This means that developers who understand the problem domain are able to contribute to the project in a highly visible, valuable way. With Agile, a developer who can say, “From here, we can also add this functionality fairly easily, and it will get us a lot of value,” or “Gee, that requirement really doesn’t match the usage patterns our logs show” will excel. As much as many developers resist the idea of having to know anything about the problem domain at all, it is undeniable that increasing numbers of organizations prefer (if not require) developers to at least understand the basics.
9: Development “hygiene”
(養成開發的良好習慣)
A few years ago, many (if not most) shops did not have access to bug tracking systems, version control, and other such tools; it was just the developers and their IDE of choice. But thanks to the development of new, integrated stacks, like the Microsoft Visual Studio Team System, and the explosion in availability of high quality, open source environments, organizations without these tools are becoming much less common. Developers must know more than just how to check code in and out of source control or how to use the VM system to build test environments. They need to have a rigorous habit of hygiene in place to make sure that they are properly coordinating with their teams. “Code cowboys” who store everything on a personal USB drive, don’t document which changes correspond to which task item, and so on, are unwelcome in more traditional shops and even more unwelcome in Agile environments, which rely on a tight coordination between team members to operate.
10: Mobile development
(行動程式開發)
The late 1990s saw Web development rise to mainstream acceptance and then begin to marginalize traditional desktop applications in many areas. In 2008, mobile development left the launch pad, and over the next five years, it will become increasingly important. There are, of course, different approaches to mobile development: Web applications designed to work on mobile devices, RIAs aimed at that market, and applications that run directly on the devices. Regardless of which of these paths you choose, adding mobile development to your skill set will ensure that you are in demand for the future.
參考:
Date: April 1st, 2009
Author: Justin James
10 skills developers will need in the next five years
(主流程式開發)
Unless there is a radical shift in the development world (akin to an asteroid hitting Redmond), most developers will need to know at least one of the Big Three development systems — .NET (VB.NET or C#), Java, or PHP — for the near future. It’s not enough to know the core languages, either. As projects encompass more and more disparate functionality, you’ll need to know the associated frameworks and libraries more deeply.
2: Rich Internet Applications (RIAs)
(豐富內涵的網路應用程式)
Love it or hate it, in the last few years, Flash is suddenly being used for more than just animations of politicians singing goofy songs. Flash has also sprouted additional functionality in the form or Flex and AIR. Flash’s competitors, such as JavaFx and Silverlight, are also upping the ante on features and performance. To make things even more complicated, HTML 5 is incorporating all sorts of RIA functionality, including database connectivity, and putting the formal W3C stamp on AJAX. In the near future, being an RIA pro will be a key resume differentiator.
3: Web development
(Web程式開發)
Web development is not going away anytime soon. Many developers have been content to lay back and ignore the Web or to just stick to “the basics” their framework provides them with. But companies have been demanding more and more who really know how to work with the underlying technology at a “hand code” level. So bone up on JavaScript, CSS, and HTML to succeed over the next five years.
4: Web services
( Web服務)
REST or SOAP? JSON or XML? While the choices and the answers depend on the project, it’s getting increasingly difficult to be a developer (even one not writing Web applications) without consuming or creating a Web service. Even areas that used to be ODBC, COM, or RPC domains are now being transitioned to Web services of some variety. Developers who can’t work with Web services will find themselves relegated to legacy and maintenance roles.
5: Soft skills
(溝通協調技巧)
One trend that has been going for quite some time is the increasing visibility of IT within and outside the enterprise. Developers are being brought into more and more non-development meetings and processes to provide feedback. For example, the CFO can’t change the accounting rules without working with IT to update the systems. And an operations manager can’t change a call center process without IT updating the CRM workflow. Likewise, customers often need to work directly with the development teams to make sure that their needs are met. Will every developer need to go to Toastmasters or study How to Win Friends and Influence People? No. But the developers who do will be much more valuable to their employers — and highly sought after in the job market.
6: One dynamic and/or functional programming language
(至少一種dynamic and/or functional 程式語言)
Languages like Ruby, Python, F#, and Groovy still aren’t quite mainstream – but the ideas in them are. For example, the LINQ system in Microsoft’s .NET is a direct descendent of functional programming techniques. Both Ruby and Python are becoming hot in some sectors, thanks to the Rails framework and Silverlight, respectively. Learning one of these languages won’t just improve your resume, though; it will expand your horizons. Every top-flight developer I’ve met recommends learning at least one dynamic or functional programming language to learn new ways of thinking, and from personal experience, I can tell you that it works.
7: Agile methodologies
(敏捷的作業方式)
When Agile first hit mainstream awareness, I was a skeptic, along with many other folks I know. It seemed to be some sort of knee-jerk reaction to tradition, throwing away the controls and standards in favor of anarchy. But as time went on, the ideas behind Agile became both better defined and better expressed. Many shops are either adopting Agile or running proof-of-concept experiments with Agile. While Agile is not the ultimate panacea for project failure, it does indeed have a place on many projects. Developers with a proven track record of understanding and succeeding in Agile environments will be in increasingly high demand over the next few years.
8: Domain knowledge
(專業領域知識)
Hand-in-hand with Agile methodologies, development teams are increasingly being viewed as partners in the definition of projects. This means that developers who understand the problem domain are able to contribute to the project in a highly visible, valuable way. With Agile, a developer who can say, “From here, we can also add this functionality fairly easily, and it will get us a lot of value,” or “Gee, that requirement really doesn’t match the usage patterns our logs show” will excel. As much as many developers resist the idea of having to know anything about the problem domain at all, it is undeniable that increasing numbers of organizations prefer (if not require) developers to at least understand the basics.
9: Development “hygiene”
(養成開發的良好習慣)
A few years ago, many (if not most) shops did not have access to bug tracking systems, version control, and other such tools; it was just the developers and their IDE of choice. But thanks to the development of new, integrated stacks, like the Microsoft Visual Studio Team System, and the explosion in availability of high quality, open source environments, organizations without these tools are becoming much less common. Developers must know more than just how to check code in and out of source control or how to use the VM system to build test environments. They need to have a rigorous habit of hygiene in place to make sure that they are properly coordinating with their teams. “Code cowboys” who store everything on a personal USB drive, don’t document which changes correspond to which task item, and so on, are unwelcome in more traditional shops and even more unwelcome in Agile environments, which rely on a tight coordination between team members to operate.
10: Mobile development
(行動程式開發)
The late 1990s saw Web development rise to mainstream acceptance and then begin to marginalize traditional desktop applications in many areas. In 2008, mobile development left the launch pad, and over the next five years, it will become increasingly important. There are, of course, different approaches to mobile development: Web applications designed to work on mobile devices, RIAs aimed at that market, and applications that run directly on the devices. Regardless of which of these paths you choose, adding mobile development to your skill set will ensure that you are in demand for the future.
參考:
Date: April 1st, 2009
Author: Justin James
10 skills developers will need in the next five years
訂閱:
文章 (Atom)
