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.

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

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了。

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(" ")); Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl(" ")); Controls.Add(new LiteralControl("")); Controls.Add(new LiteralControl(" ")); 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("
"));
txtMessage = new Label();
txtMessage.ID = "txtMessage";
txtMessage.Visible = true;
txtMessage.ForeColor = System.Drawing.Color.Red;
Controls.Add(txtMessage);
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

2009年10月13日 星期二

C# Programing Notes

1. How to check object null


2. How to check db object null
if(myDataSet.Rows[0]["columnName"] == DBNull.Value)

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

2009年8月11日 星期二

防止多次SUBMIT的方法

WEB FORM中,有時後使用者按下『SUBMIT』時,連接至SERVER過慢,忍不住多按幾下,有時會造成多次執行的結果,例如資料重複或是EMAIL重複發出。

要防止這個問題,以下是最簡單的方式:
-------------------------------------------------------------------------

<script language="javascript">
var submitted = false;
</script>

...

<form onsubmit="if (!submitted) {submitted = true; return true;} else return false;">

...

-------------------------------------------------------------------------

說明:
1. 一定要在CLIENT端處理,因此選用Javascript
2. 有些人用的方式是DISABLE SUBMIT按鈕,但是每支程式的都不同,很難達成
3. 利用一般form的檢查機制,輕易完成此一任務
4. 若有其他form的檢查機制需要自行調整
5. ASP.NET的MASTER PAGE,也可以套用,甚至更方便,只要改一個地方即可
6. 此方法適用各類WEB語言



2009年8月4日 星期二

Cascading Dropdown List(多層次) 初值設定 (ASP.NET)

Cascading Dropdown List(多層次)的製作在各種程式中應用廣泛,也有需多人提出實例教學,因此不在此多說。

一般Cascading Dropdown List(多層次)是應用於資料查詢上,但是若是應用在資料編輯,就遇到有設定初值的問題。

方法如下:
(以2階為例、兩個Dropdown List:List1, List2、初值分別是value1, value2)
1. 先將List1的Items設定好
2. List1.SelectedValue = value1;
3. 依據List1初值value1,設定好List2的Items
4. List2.SelectedValue = value2;

若List2有data binding,則步驟3可以改為:
List2.Items.Clear();
SqlDataSource2.SelectParameters[0].DefaultValue = value1;
DataView view = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
SqlDataSource2.DataBind();

2009年7月22日 星期三

Report tools for .Net and ASP.Net

找 Report tools 的評量條件:
1. 報表製作工具(Designer)的容易上手
2. Viewer:效能,供分頁、換頁,查詢
3. 列印功能
4. 支援多種匯出格式
5. 簡單的報表可以快速產出
6. 中文支援&中文字體支援
7. 對樞紐分析報表的支援
8. 安裝及建置的便利性(例如:client是否要裝VIEWER、Server是否要裝軟體)
9. 同時支援Win-Form & Web-Form

常見的TOOLS
1. 一般作元件的廠商都有提供報表元件及TOOL:
DevExpress, ComponentOne, Telerik
2. 其他以報表製作工具為主的廠商:
Dundas, Crystal Reports

參考資料: www.componentsource.com

[技術筆記] SQL Server Full-text Search全文檢索

--Implementing Full Text Search with T-SQL stored Procedures / Eli Leiba
Enabeling Full Text search in T-SQL is usually not so "popular" as doing it with the EnterPrize Manager
So Here are the T-SQL steps you have to do in order to implement FTS in T-SQL

--1 Enabling full text on the database
EXEC sp_fulltext_database 'enable'

--2 Create the Catalog (if does not exist)
EXEC sp_fulltext_catalog 'MyCatalog','create'

--3 add a full text index on a Table
EXEC sp_fulltext_table 'Products', 'create', 'MyCatalog', 'pk_products'
EXEC sp_fulltext_table 'Categories', 'create', 'MyCatalog', 'pk_categories'

--4 add a column to the full text Index
EXEC sp_fulltext_column 'Products', 'ProductName', 'add'
EXEC sp_fulltext_column 'Categories', 'Description', 'add'

--5 activate the index
EXEC sp_fulltext_table 'Products','activate'
EXEC sp_fulltext_table 'Categories','activate'

--6 start full population
EXEC sp_fulltext_catalog 'MyCatalog', 'start_full'

-- usage in T-SQL (CONTAINS and FREETEXT predicates)
-- Using the index in T-SQL
USE Northwind
GO
SELECT ProductId, ProductName, UnitPriceFROM Products
WHERE CONTAINS( ProductName, ' "sasquatch " OR "stout" ' )
GO
USE Northwind
GO
SELECT CategoryNameFROM Categories
FREETEXT (Description, 'sweetest candy bread and dry meat' )
GO

2009年7月21日 星期二

[技術筆記] SharePoint 2007 開發與管理需要的工具與軟體

[技術筆記] Repeater中尋找控制項

作  者:黃家瑞 精誠資訊 恆逸教育訓練中心講師
技術分類:程式設計

Repeater
開發ASP.NET程式時,Repeater是一個非常實用的控制項,可是實際操作時總會遇到點瓶頸,就像以下的例子(以北風northwind資料庫作為例子),當完成了將員工資料利用Repeater載入網頁後,面臨一個頭痛的問題,在每個Itemtemplate裡面的按鈕,btnCalc按下去後,希望可以算出該項目的資料(這裡以計算出到目前為止的年資為例),問題是,怎麼”找到”這一個項目中的控制項內容?
"    SelectCommand="SELECT [EmployeeID], [FirstName], [LastName], [HireDate]            FROM [Employees]">







  EmployeeId:<%#Eval("EmployeeId") %>


  Name:<%#Eval("FirstName") %> <%#Eval("LastName") %>


  HireDate:' />


  

  

  




>  


利用一個簡單的語法就可以找到按鈕旁邊的Label控制項。
protected void btnCalc_Click(object sender, EventArgs e) {
Label lblDate = (Label)((Button)sender).NamingContainer.FindControl("lblHireDate"); Label lblYr = (Label)((Button)sender).NamingContainer.FindControl("lblYear");   DateTime d;
if (DateTime.TryParse(lblDate.Text, out d))
 lblYr.Text = (DateTime.Today.Subtract(d).Days / 365.0).ToString("#.00");
}

NamingContainer可以在Repeater中找到目前控制項的容器(Container),在這個容器中,找到該控制項。這樣子就可以很容易的操作在Repeater中的控制項了。



2009年7月1日 星期三

SharePoint 2007書籍

1. Microsoft SharePoint 2007 Development Unleashed
by Kevin Hoffman‧Robert Foster
悅知有出翻譯版 : http://www.delightpress.com.tw/book.aspx?book_id=SKTP00022
某些章節可以一讀,或是先看這本,然後再詳讀下一本

2. Inside Microsoft Windows SharePoint Services 3.0
by Ted Pattison; Daniel Larson
非常詳盡的說明SharePoint的架構與客製的作法,值得一讀

2009年1月21日 星期三

Sharepoint 2007(MOSS) 應用程式開發模式

Option 1: Custom built Web Parts
With this option you build all your UI using the Web Part framework. Logic etc... can be off in other .Net assemblies or a web service etc... just as you would with any other .Net Application.
Pros:
Built using ASP.Net Web Part framework
Deployed via Web Part install package or the new Feature/Solution Deployment mechanism
SharePoint application provides hosting framework for "putting" these Web Parts on Web Part pages
Communications framework for talking with other Web Parts
Designed to be highly re-usable across many sites with little effort
Cons:
No drag and drop UI for laying out your UI i.e. no design time surface
A framework that developers must learn to work within
Summary: A good use of web parts would be where you want to build a widget/mini-application that you can put on many web part pages across many sites.

Option 2: _layouts application
An _layouts application is when you develop an ASP.Net Web Application and deploy it to the c:\program files\common files\microsoft shared\web server extensions\12\template\layouts (what a mouthful!) directory. This is a special directory that gets "virtualized" in each sharepoint site i.e. in each sharepoint site you will have an /_layouts path from the root of the web. E.g. http://servername/sites/sitename/_layouts.
This means you can make your application available under each SharePoint site e.g. http://servername/sites/sitename/_layouts/MyApp/SomePage.aspx
In fact this is how all the SharePoint administration pages are delivered in each site.
Pros:
Great way to make your functionality available in every site
Easy to develop. It is just like developing a regular ASP.Net web site
Context sensitive access to the SharePoint object model. Great for doing work on the site that the user happens to be working in at the time.
Cons:
Deployment not managed via Solution deployment mechanism
Cant use the ASP.Net master page of the site context as the _layouts application is a separate ASP.Net application
Summary: It is best to use an _layouts based application when you want to extend every site with some functionality such as additional administration pages.

Option 3: User Controls and the Son of SmartPart
The last option is to build your applications UI in ASP.Net User Controls as you would with any other ASP.Net Web Application and then use the Son of SmartPart to deliver those User Controls via a web part.
The Son of SmartPart is a Web Part that is able to "host" an ASP.Net 2.0 User Control :) For more info on this see: http://www.smartpart.info/default.aspx(if you are wondering who its father is ... that is the SmartPart funnily enough ... and is a Web Part for hosting ASP.Net 1.1 User Controls)
Pros:
Simple development experience.
You get a design surface to build you UI
Deployment reasonably straight forward
Can use Web Part connection framework if desired
Might be possible to develop these outside of SharePoint first (depending on if they have dependencies to SharePoint).
Cons:
Deployment not managed via Solution deployment mechanism Out of the Box (you could build a solution to deploy the Son of Smart Part)
Slightly different deployment of User Control files and assemblies (but nothing a .bat file can't fix) during development.
Summary: I think this is a great option when you want to build a rich browser based UI that you only want to use in one (or a couple) of sites. I don't think this is a good option if you want to build a mini-application that you want to include on many sites. A better option in that case might be a Web Part.

Option 4: ASPX pages added to SharePoint Site
This option actually was suggested in the comments by a reader. I thought it was so good i tried it out ... and it works great! So here it is.
This option allows you to add your ASP.Net application pages into your SharePoint Site. It also provides for compiling all using the code behind your pages into a DLL.
In a nutshell this option allows you to build your ASP.Net application outside of SharePoint, build it, test it & then add it to SharePoint. Its great!

Here is how to do it:
1. Install the Visual Studio 2005 Web Application Projects extension. This gives you the 'old style' web projects in Visual Studio ... so you can compile down to a single DLL etc...
2. START - File - New Project - ASP.NET Web Application - Name it "ItDoesWork"
3. Add reference to Microsoft.Sharepoint
Leave only Microsoft.SharePoint, System, and System.Web
4. In the Solution Explorer create folder "~masterurl" and add masterpage "default.master" inside
5. Replace code behind for the masterpage with:
using System;using Microsoft.SharePoint;namespace ItDoesWork._masterurl{
public partial class _default : System.Web.UI.MasterPage{
protected void Page_Load(object sender, EventArgs e){}
}
}
6. In the designer, rename ContentPlaceHolder's ID to "PlaceHolderMain"
7. Delete Default.aspx, and add new page - SamplePage.aspx
8. Replace source content with the following:
<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" CodeBehind="SamplePage.aspx.cs" Inherits="ItDoesWork.SamplePage" Title="Untitled Page" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>

Testing Page...


9. Replace code behind for the page with:
using System;using Microsoft.SharePoint;
namespace ItDoesWork{
public partial class SamplePage : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
Label1.Text = SPContext.Current.Site.Url;
}
}
}
10. Project properties - Build - Output path:
Point it to \BIN folder of our SharePoint Web application. E.g.
C:\Inetpub\wwwroot\wss\VirtualDirectories\moss.litwareinc.com80\bin
You can also manually copy your projects DLL into the \BIN folder each time.
11. Compile your project.
12. Open the web.config file for the SharePoint Web Applicaiton E.g.
C:\Inetpub\wwwroot\wss\VirtualDirectories\moss.litwareinc.com80\web.config
13. Add the following line to the SafeControls section (change to suit your assembly and namespace etc...)

14. Change the line to
15. Open your site in SharePoint Designer and drag and drop your SamplePage.aspx page into a folder in your site.
16. Browse to your page E.g.
http://moss.litwareinc.com/TestApp/TestPages.aspx
17. Jackpot! (Hopefully) You should now have your aspx page running in SharePoint.
One of the great things about this option is that you could build your applicaiton outside of SharePoint with any old MasterPage, then deploy to SharePoint and swap out the masterpage string for the correct one. Thus being able to develop and debug outside of SharePoint and then deploy and test inside SharePoint.
I can see this option being a favorite for most ASP.Net developers who are used to the integrated/seemless code, build & debug experience.
A note on debugging: If you want to debug your code once it is running inside SharePoint then all you need to do is attach the Visual Studio debugger to the correct w3wp.exe process (Debug -> Attach to process), set your break points and then hit your page in a browser.
Pros:
Simple development experience. Develop outside SharePoint first if desired.
You get a design surface to build you UI
Deployment reasonably straight forward
Cons:
Deployment not managed via Solution deployment mechanism Out of the Box. ( but this might be possible i have not tried it yet)
Slightly different deployment of User Control files and assemblies (but nothing a .bat file can't fix) during development.
I really like this option ... coming from an ASP.Net point of view i feel it is a simple option.


正在測試Option 4,會將結果再報告出來。

參考資料
http://blogs.msdn.com/cjohnson/archive/2006/09/05/740498.aspx

建立Sharepoint 2007(MOSS) 應用程式開發環境

所需軟體:
以上軟體可由MSDN License、 Microsoft 或相關網站免費取得, 除了 BDC Metadata Manager. BDC Metadata Manager有免費簡易版本可下載.