小白樂園
對於亞當,天堂是他的家,而他的後裔,家就是天堂。-伏爾泰
標籤
程式設計
隨筆
Android
ASP.NET
C#
groovy
VBA
Window Form
2017年1月31日 星期二
Excel巨集應用-篩選
不太會用公式
但是我會用巨集阿哇哈哈哈
留作紀錄下次不用重打了
Sub 篩選()
Dim R, C As Integer
R = 2: C = 6:
Do While Cells(R, C).Value <> ""
If Cells(R, C).Value <> "桃園專車" And Cells(R, C + 1).Value <> "桃園專車" Then
Rows(R).Delete Shift:=xlUp
Else: R = R + 1
End If:
Loop:
End Sub
2016年11月28日 星期一
ASP.NET C# 動態新增textbox且讀取輸入的值
Default.aspx:
Default.aspx.cs:
Button1:動態新增一個textbox,ID="txt_1"
Button2:讀取txt_1.text放到label
程式碼:
protected void Page_Load(object sender, EventArgs e)
{
if( ViewState["Ctl_count"]!=null)
{
TextBox txb = new TextBox();
txb.ID = "txt_1";
Panel1.Controls.Add(txb);
ViewState["Ctl_count"] = 1;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox txb = new TextBox();
txb.ID = "txt_1";
Panel1.Controls.Add(txb);
ViewState["Ctl_count"] = 1;
}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox txb = (TextBox)Panel1.FindControl("txt_1");
Label1.Text = txb.Text;
}
程式重點:
由於動態新增的物件會在按Button2的時候,跑到Load整個洗掉,所以利用 ViewState["Ctl_count"] 來記錄擬新增了幾個物件。
我這個範例固定新增一個看不太出來,但是如果是不能確定會新增幾個的時候就很需要了。
如果是一開始就直接動態新增可以寫進Page_Init裡面。
控制項的初始化(Initialize)的動作一定要放在 Page_Init 事件中!控制項的初始化也包括設定控制項的預設值(Default Value)。
千萬不能將設定控制項初始值的程式碼寫在 Page_Load 事件裡,否則當 PostBack 回來的值會被 Page_Load 事件中的程式碼蓋掉
。動態將控制項加入到 ASP.NET 頁面中「最好」在 Page_Load 事件中執行,以確保在後續事件中可以取得頁面中所有的控制項。==>這是網路上找的原話
2016年9月14日 星期三
ASP.NET 擴充套件-網頁文字編輯器CKEditor
下載:
官方網站:http://ckeditor.com/download
使用前:
把ckeditor_aspnet_3.6.6.2\bin\Release\CKEditor.NET.dll
加入工具箱內就可以用了
步驟:工具箱內隨意右鍵=>選擇項目=>瀏覽=>選CKEditor.NET.dll=>確定
使用:
<script src="//cdn.ckeditor.com/4.6.0/basic/ckeditor.js"></script>
<CKEditor:CKEditorControl ID="CKEditorControl1" runat="server"></CKEditor:CKEditorControl>
較新的文章
較舊的文章
首頁
訂閱:
文章 (Atom)