Xem so sánh các bản VS 2005 tại đây
Tháng Chín 27, 2007
Tháng Chín 24, 2007
Javascript tutorial & examples
Tham khảo javascript toàn tập. Có kèm trình soạn thảo online.
Deploy to server using CLickOnce
Để deploy application lên server dùng ClickOnce. Server cần có
- IIS
- FrontPage 2002 Server Extensions.
Tuy nhiên, khi publish lên server, sẽ gặp những vấn đề sau:
| Error 7 Failed to connect to ‘http://server IP/Projects/’ with the following error: Unable to create the Web ‘http://server IP/projects/’. Server error: Error 5 opening registry key “SOFTWARE\Classes” | |
| => |
Do FrontPage server extensions không có quyền access vào key HKEY_LOCAL_MACHINE\SOFTWARE\Classes. |
| => |
|
| Error 7 Failed to connect to ‘http://server IP/Projects/’ with the following error: Unable to create the Web ‘http://server IP/projects/’. Server error: Error 5 opening registry key “SOFTWARE\Classes\.hlp” | |
| => |
Nguyên nhân và cách khắc phục tương tự như trên. |
Tháng Chín 23, 2007
ASP.NET AJAX progress indicator
Dưới đây là cách làm progress indicator trong asp.net với Atlas (MS Ajax). Khi ấn vào sẽ có 1 cái hình xoay xoay và con trỏ chuột trở thành waiting. Trông cũng hay phết. Bài này là bài sưu tầm. Ghi qua đây để tiện lấy ra khi cần.
Source trang aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="UpdatePanelAnimation" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Update Panel with Animation</title>
<link href="UpdatePanelAnimation.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="Container" class="Normal">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Update Me" /><br /><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html></asp>
Souce code behind c#
public partial class UpdatePanelAnimation : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Thread.Sleep(5000);
Label1.Text = DateTime.Now.ToString();
}
}
Souce css
.Normal
{
border: dashed 1px #000000;
background-color: #FFFFFF;
cursor: auto;
padding: 10px;
width: 200px;
text-align: center;
}
.Progress
{
border: dashed 1px #000000;
background-color: #EEEEEE;
background-image: url(spinner.gif);
background-position: center center;
background-repeat: no-repeat;
cursor: wait;
padding: 10px;
width: 200px;
text-align: center;
}
Cuối cùng là source javascript để handle event
<script language="javascript">
// Get a reference to the PageRequestManager.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Using that prm reference, hook _initializeRequest
// and _endRequest, to run our code at the begin and end
// of any async postbacks that occur.
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
// Executed anytime an async postback occurs.
function InitializeRequest(sender, args)
{
// Change the Container div's CSS class to .Progress.
$get('Container').className = 'Progress';
// Get a reference to the element that raised the postback,
// and disables it.
$get(args._postBackElement.id).disabled = true;
}
// Executed when the async postback completes.
function EndRequest(sender, args)
{
// Change the Container div's class back to .Normal.
$get('Container').className = 'Normal';
// Get a reference to the element that raised the postback
// which is completing, and enable it.
$get(sender._postBackSettings.sourceElement.id).disabled = false;
}
</script>
Tháng Chín 22, 2007
Các level transaction (IsolationLevel Enumeration)
Specifies the transaction locking behavior for the connection.
The IsolationLevel values are used by a .NET Framework data provider when performing a transaction.
The IsolationLevel remains in effect until explicitly changed, but it can be changed at any time. The new value is used at execution time, not parse time. If changed during a transaction, the expected behavior of the server is to apply the new locking level to all statements remaining.
| Member name | Description |
|---|---|
| Chaos | The pending changes from more highly isolated transactions cannot be overwritten. |
| ReadCommitted | Shared lock sẽ giữ khi data đang đọc để tránh dirty reads, nhưng data có thể thay đổi trước khi kết thúc một transaction. Kết quả là non-repeatable reads hay phantom data. |
| ReadUncommitted | A dirty read is possible, meaning that no shared locks are issued and no exclusive locks are honored. |
| RepeatableRead | Lock được đặt trên toàn data query, ngăn không cho người khác update data trong khi thực hiện transaction. Ngăn ngừa được việc đọc không liên tục nhưngphantom rows vẫn có thể xuất hiện. |
| Serializable | A range lock đặt trong DataSet, không cho users khác update hay insert row vào dataset cho tới khi transaction complete. |
| Snapshot | Giảm blocking bằng cách lưu 1 version của data để một ứng dụng có thể đọc trong khi một ứng dụng khác modify data. Trong một transaction đó sẽ không thể nhận được sự thay đổi data cho dù requery. |
| Unspecified | A different isolation level than the one specified is being used, but the level cannot be determined.When using OdbcTransaction, if you do not set IsolationLevel or you set IsolationLevel to Unspecied, the transaction executes according to the default isolation level of the underlying ODBC driver. |
(Chỉ dịch trước chỗ nào quan trọng và sử dụng nhiều thôi.)
Tháng Chín 19, 2007
Exit sub vs Return in VB.NET
Hiện tại, sau khi search lung tung, chưa thấy sự khác nhau giữa Exit Sub và Return cho nên => Xài cái nào cũng được.
Tuy nhiên, vì exit sub cũ rồi, nên nếu xài thì cũng không hay lắm. Nên xài return cho nó mới mẻ. Chứ cũng chả ý nghĩa gì khác.
Tham khảo đây: http://www.ondotnet.com/pub/a/dotnet/excerpt/vbnetnut_appa/index.html?page=4
Tháng Chín 18, 2007
ClickOnce Deployment complete reference
Tham khảo ClickOnce deployment toàn tập
http://msdn2.microsoft.com/en-us/library/t71a733d(VS.80).aspx
SQL Server 2005 Features Comparison
Bảng so sánh các edition của SQL 2005 với nhau. Rất có ích khi lựa 1 bản để xài.
Customize Crystal Report data
1. Set database logon info:
There is 2 ways to set database logon info.
1. Using SetDatabaseLogon
rpt.SetDatabaseLogon(username, password, server, database)
However, sometime using SetDatabaseLogon won’t effect. At that time, uses TableLogOnInfo to apply logon info for each table in report source.
Dim t As New TableLogOnInfo t.ConnectionInfo.UserID = AppSettingsInfo.GetDBUserSettings t.ConnectionInfo.Password = AppSettingsInfo.GetDBPasswordSettings t.ConnectionInfo.ServerName = AppSettingsInfo.GetDBHostSettings rpt.Database.Tables(0).ApplyLogOnInfo(t)
2. Set record selection formula:
strWhere = "{ReportQuery.Column1} = " + strColumn1Condtion
strWhere = "{ReportQuery.Column2} = " & strColumn2Condtion
rpt.RecordSelectionFormula = strWhere
3. Set sort data:
rpt.DataDefinition.SortFields(0).Field = rpt.Database.Tables(0).Fields("Column1")
rpt.DataDefinition.SortFields(0).SortDirection = SortDirection.AscendingOrder
Pass Discrete Value in CR
Pass value for discrete parameter of crystal report in Visual Studio 2005.
DataTable dat;
CampaignListTableAdapter objAdpt = new CampaignListTableAdapter();
dat = objAdpt.GetCampaignList();
string strServerPath = Server.MapPath(".");
string strFullPath = Path.Combine(strServerPath, "RecentlySubmmited.rpt");
ReportDocument objReport = new ReportDocument();
objReport.Load(strFullPath);
objReport.SetDataSource(dat);
//Pass Discrete Value
ParameterDiscreteValue crValue = new ParameterDiscreteValue();
crValue.Value = "Recently Submitted";
ParameterFields objFields = objReport.ParameterFields;
objFields["Title"].CurrentValues.Add(crValue);
//Export to HTTP stream
objReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "RecentlySubmitted");