2010/05/15

[Silverlight 4] 列印功能

1. 引入 namespace
System.Windows.Printing

2. 建立 PrintDocument
3. 建立對應 Event
  • BeginPrint
  • EndPrint
  • PrintPage - e.PrintVisual (指定列印目標物件), 確認 e.HasMorePages (是否有多頁)
4. 最後指定 PrintDocument 物件 Print 的文件名稱
Print("MyDocument")

2010/05/06

[ASP.NET] 轉換 ArrayList 至字串陣列

VB:

Dim str() As String = arrList.ToArray(GetType(String))

C#:

string[] strings = (string[])arrList.ToArray(typeof(string));

2010/05/03

[.NET] Bitmap to byte array

byte[] bytes = (byte[])System.ComponentModel.TypeDescriptor.GetConverter(bmp).ConvertTo(bmp, typeof(byte[]));

參考網址: Bitmap to byte array

2010/04/27

[ASP.NET] Forms 登入驗證

命名空間
System.Web.Security

驗證
FormsAuthentication.RedirectFromLoginPage(username, true)

登出
FormsAuthentication.SignOut()

查證是否驗證
User.Identity.IsAuthenticated

ASP.NET MVC (在 Controller 的 Action 前加 Authorize 屬性)
[Authorize]
e.g.
[Authorize]
public ActionResult Index() { return View(); }



相關資料:

[ASP.NET] 類別中讀取 Session

匯入命名空間
Imports System.Web.HttpContext

在類別中使用Session
Current.Session("sessionName")