增加一個event 讓 Process 在執行完畢的時候判斷用
private static void process_Exited(object sender, EventArgs e) {
Console.WriteLine("Notepad.exe 已被關閉!!!");
}
增加一個event 讓 Process 在執行完畢的時候判斷用
private static void process_Exited(object sender, EventArgs e) {
Console.WriteLine("Notepad.exe 已被關閉!!!");
}
程式碼如下
string AD_RootPath = "LDAP://AD的IP或是電腦名稱/cn=Users,dc=網域,例:example,dc=網域,例:com";
DirectoryEntry entry = new DirectoryEntry(AD_RootPath, 帳號,密碼, AuthenticationTypes.Secure);
DirectorySearcher deSearch = new DirectorySearcher(entry);
foreach (SearchResult res in deSearch.FindAll())
{
foreach (string key in res.Properties.PropertyNames)
{
foreach (object val in res.Properties[key])
{
string v=key+"="+val;
Response.Write(v + "<BR>");
}
}
Response.Write( "------------------------------------------------------------------------------------------------<BR>");
}
參考:http://blog.xuite.net/yan.kee/CSharp/14844624?ref=rel
解法如下
C# 加上下面的CODE就OK了
public override void VerifyRenderingInServerForm(Control control)
{
好站:http://www.flounder.com/csharp_color_table.htm
using System.Drawing;
color c=Color.FromKnownColor(KnownColor.DarkRed);
KnownColor.DarkRed<==使用系統預設顏色碼
上面網站有詳細的顏色對照。
使用Regex 還有 MatchCollection, 引用命名空間using System.Text.RegularExpressions;
方法如下
1 |
MatchCollection mc; |
ChartFX 是一個很強大的圖表軟體, 特別是到了 2005 的版本之後, 運用了 DHTML 和 AJAX 的技術, 讓原先要透過安裝 ActiveX 才能達到的效果, 也可以直接在網頁上呈現, 而且互動性也像 ActiveX 一樣的好, 但是代價就是要多付出一些 server 和 client 之間資料的來回傳送!
在實際使用 ChartFX 7.0 開發 Web App 的時候, 發現了一個現象, 就是如果透過 Visual Studio 內建的 WebDev.WebServer.exe 啟動的話, ChartFX 的暫存檔會輸出到 ~/chartfx70/temp/ 底下, 可是當佈署到 IIS 之後, 它會在 WebSite 的根目錄下建立一個 /chartfx70 虛擬目錄, 這時候如果透過 ISA 將內部網站發佈出去的話, 除了要開放該 Web 應用程式的路徑之外, 就還要再多開放一個 /chartfx70 的路徑, 外部的人才可以順利的取得 chart 的內容, 雖然動作不難, 但是還要動到 ISA 的設定也是有點不方便, 所以才想找個方法讓 chartfx 的輸出路徑改變一下!
在 google 上找了很久, 其實沒有找到答案, 但是有找到一點點看起來不太像的線索, 最後還是透過 Reflector 才搞定了這個問題!!
asp.net 2.0 使用
在PostBack後網頁通常會回到最頂端的位置,下面三個方式可以讓單頁或整個Web或目錄PostBack後回到原來停留的位置.
1. Web.config
1 |
//在<system.web></system.web>之間增加節點 |
2 |
<pages maintainScrollPositionOnPostBack= "true" ></pages> |
A potentially dangerous Request.Form value was detected from the client (ctl00$MainContent$txtCode="<code></code>").
好吧!這一次真的是我太嫩了!短短接觸 .NET 平台雖然不到半年,我這次認栽了!
今天,就為了這小小的 Bug,不知道浪費多久的時間,殺死了多少的腦細胞!唉!只能說我還是太嫩了,寫的程式不夠多!還以為真的是七月,見到鬼了,一行一行 trace,明明眼看 TextBox 中有值,卻無法取用!幸好, Google 讓我搜尋到解答,早在 2005 的時候,就有人提出解決辦法了!Orz
解決之道:
在很多程式裡都有四捨五入Round的功能,但其四捨五入的結果是否真如預期?負數的四捨五入是什麼結果? 以下用JavaScript / .Net / Oracle /MS SQL /Excel 這幾種語言或工具來看看,結果都是出乎預料之外...
此程序利用 WinRAR 程序对文件进行压缩,命令行语法可参考WinRAR中文帮助。
在dos或者cmd下用cd命令进入到winrar的安装目录后,输入unrar可出来以下提示:
在 .aspx.cs 可以使用 Server.MapPath() or Request.MapPath() 來取伺服器的實體路徑,不過在Class檔中是沒有這兩個玩意的
所以就用 HttpContext.Current.Server.MapPath("/MyWeb") 來抓路徑,引號內為 IIS 資料夾位置,若只有 "/" 則取根目錄
參考:http://www.dotblogs.com.tw/jjwei/archive/2010/10/07/18185.aspx
<%@ Page language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Drawing" %>
<html>
<head>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
// Create a TableItemStyle object that can be
// set as the default style for all cells
// in the table.
TableItemStyle tableStyle = new TableItemStyle();
tableStyle.HorizontalAlign = HorizontalAlign.Center;
tableStyle.VerticalAlign = VerticalAlign.Middle;
tableStyle.Width = Unit.Pixel(100);
// Create more rows for the table.
for (int i = 2; i < 10; i++)
{
TableRow tempRow = new TableRow();
for (int j = 0; j < 3; j++)
{
TableCell tempCell = new TableCell();
tempCell.Text = "(" + i + "," + j + ")";
tempRow.Cells.Add(tempCell);
}
Table1.Rows.Add(tempRow);
}
// Apply the TableItemStyle to all rows in the table.
foreach (TableRow r in Table1.Rows)
foreach (TableCell c in r.Cells)
c.ApplyStyle(tableStyle);
// Create a header for the table.
TableHeaderCell header = new TableHeaderCell();
header.RowSpan = 1;
header.ColumnSpan = 3;
header.Text = "Table of (x,y) Values";
header.Font.Bold = true;
header.BackColor = Color.Gray;
header.HorizontalAlign = HorizontalAlign.Center;
header.VerticalAlign = VerticalAlign.Middle;
// Add the header to a new row.
TableRow headerRow = new TableRow();
headerRow.Cells.Add(header);
// Add the header row to the table.
Table1.Rows.AddAt(0, headerRow);
}
</script>
</head>
<body>
<form runat="server">
<h1>TableCell Example</h1>
<asp:table id="Table1" runat="server" CellPadding="3" CellSpacing="3">
<asp:TableRow>
<asp:TableCell Text="(0,0)"></asp:TableCell>
<asp:TableCell Text="(0,1)"></asp:TableCell>
<asp:TableCell Text="(0,2)"></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell Text="(1,0)"></asp:TableCell>
<asp:TableCell Text="(1,1)"></asp:TableCell>
<asp:TableCell Text="(1,2)"></asp:TableCell>
</asp:TableRow>
</asp:table>
</form>
</body>
</html>
參考:
http://msdn.microsoft.com/zh-tw/library/tk1zfd2e(VS.80).aspx
http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.webcontrol.borderwidth(v=VS.80).aspx