jQuery("input#<%=FileUpload1.ClientID %>").change(function () {
alert(jQuery(this).val());
});
2014年7月27日 星期日
C# Asp.net FIleUpload event listen
標籤:
JavaScript,
Jquery
2014年7月17日 星期四
JavaScript 敲打文字時,驗證整數和小數
// 驗證小數
// doc:Doc物件
function ValiFloat(doc) {
var docValue = $(doc).val();
// 驗證小數pattern
var valiPattern1 = /^\d+[.]?\d*$/;
var reValiPattern1 = /^\d+[.]?\d*/;
// 驗證數字格式pattern ,針對 01 replace 1
var valiPattern2 = /^[0]+\d+/;
var reValiPattern2 = /[1-9]\.?\d*/;
if (!valiPattern1.test(docValue)) {
$(doc).val(reValiPattern1.exec(docValue))
}
else if (valiPattern2.test(docValue)) {
$(doc).val(reValiPattern2.exec(docValue))
}
}
// 驗證整數
// doc:Doc物件
function ValiNumber(doc) {
var docValue = $(doc).val();
// 驗證整數pattern
var valiPattern1 = /[^0-9]/g;
// 驗證數字格式pattern ,針對 01 replace 1
var valiPattern2 = /^[0]+\d+/;
var reValiPattern2 = /[1-9]\.?\d*/;
if (doc.value != doc.value.replace(valiPattern1, '')) {
doc.value = doc.value.replace(valiPattern1, '');
}
else if (valiPattern2.test(docValue)) {
$(doc).val(reValiPattern2.exec(docValue))
}
}
// 使用方法就在Jquery 的 $(document).ready(function ()
$(document).ready(function () {
// 驗證小數
$(document).on("keyup","selector",function(){
ValiFloat(this);
})
// 驗證整數
$(document).on("keyup","selector",function(){
ValiNumber(this);
})
})
2014年7月10日 星期四
MsSql DECLARE CURSOR 資料指標
Set Nocount ON; declare @a nvarchar(100),@b nvarchar(100),@c int Declare db Cursor For select a,b from Test order by a Open db Fetch Next From f into @a, @b While @@Fetch_Status = 0 Begin //Do Something fetch next from db into @a, @b End Close db; Deallocate db;
2014年7月7日 星期一
C 第一個程式 Hello World
其實我還蠻喜歡C的,在還沒開始寫C++跟C#的時候最早接觸就是C,在我的書櫃裡有一本最老的程式設計書
2003年出版的C語言入門的學習繪本,那時候看當然什麼都看不懂
C介紹就不多講了,Google上有很多C的歷史自己去找 建置環境 Dev-C++或是VS都可以
http://wenku.baidu.com/view/aa0dea7831b765ce05081418.html http://mitblog.pixnet.net/blog/post/37451428-visual-studio-2010-%E5%AF%ABc%E3%80%81visual-studio-2010-%E5%AF%ABc%E8%AA%9E%E8%A8%80%E3%80%81vi http://debugmode.net/2012/02/06/how-to-write-and-run-a-c-program-in-visual-studio-2010/
C介紹就不多講了,Google上有很多C的歷史自己去找 建置環境 Dev-C++或是VS都可以
http://wenku.baidu.com/view/aa0dea7831b765ce05081418.html http://mitblog.pixnet.net/blog/post/37451428-visual-studio-2010-%E5%AF%ABc%E3%80%81visual-studio-2010-%E5%AF%ABc%E8%AA%9E%E8%A8%80%E3%80%81vi http://debugmode.net/2012/02/06/how-to-write-and-run-a-c-program-in-visual-studio-2010/
#include#include void main(void) { printf("Hello World"); system("pause"); }
C# Delete Process
如果您的WinAP執行了一大堆,開啟工作管理員一個一個刪除的話
那可以服用這段程式碼幫你快速刪除
那可以服用這段程式碼幫你快速刪除
foreach (Process p in Process.GetProcessesByName("process_Name")) //不需要.exe
{
p.Kill();
}
真是輕鬆又快樂
Javascript KeyDown Listener
javascript版 鍵盤按鈕Listener
程式碼的數量真是.....
相較winap真是差太多
不過GridView分頁要用鍵盤數字鍵去做分頁選擇的話
比較簡單的做法,直接放一個TextBox和一個Button
後端Page_Load裡面一個 TextBox1.Focus();
前端
<div style="position: absolute; top: -1500px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</div>
後端
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
TextBox1.Focus();
}
要注意Button2放的位置,如果上一個有Button的話,在TextBox按下ENTER 只會執行第一個Button
window.addEventListener("keydown", checkKeyPressed, false);
function checkKeyPressed(e) {
alert(e.keyCode);
if (e.keyCode == "65") {
alert("The 'a' key is pressed.");
}
}
不過GridView分頁要用鍵盤數字鍵去做分頁選擇的話
比較簡單的做法,直接放一個TextBox和一個Button
後端Page_Load裡面一個 TextBox1.Focus();
前端
<div style="position: absolute; top: -1500px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</div>
後端
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
TextBox1.Focus();
}
要注意Button2放的位置,如果上一個有Button的話,在TextBox按下ENTER 只會執行第一個Button
2014年7月6日 星期日
C# NPOI export xls
Third Part NPOI
Nuget搜尋NPOI
var workbook = new HSSFWorkbook();
var sheetReportResult = workbook.CreateSheet("結果");
sheetReportResult.CreateRow(0).CreateCell(0).SetCellValue("開始時間");
//之後的用GetRow 取得在CreateCell
sheetReportResult.GetRow(0).CreateCell(1).SetCellValue("結束時間");
sheetReportResult.GetRow(0).CreateCell(2).SetCellValue("資料大小(KB)");
sheetReportResult.GetRow(0).CreateCell(3).SetCellValue("花費時間(s)");
sheetReportResult.GetRow(0).CreateCell(4).SetCellValue("速度(KB/s)");
int i = 1;
foreach (string str in sb.ToString().Split('|'))
{
if (str != "")
{
sheetReportResult.CreateRow(i).CreateCell(0).SetCellValue(str.Split(',')[0].Replace("Start Time: ", ""));
sheetReportResult.GetRow(i).CreateCell(1).SetCellValue(str.Split(',')[1].Replace(" End Time :", ""));
sheetReportResult.GetRow(i).CreateCell(2).SetCellValue(str.Split(',')[2].Replace(" Size:", ""));
sheetReportResult.GetRow(i).CreateCell(3).SetCellValue(str.Split(',')[3].Replace(" Total:", ""));
sheetReportResult.GetRow(i).CreateCell(4).SetCellValue(str.Split(',')[4].Replace(" Speed:", ""));
i++;
}
}
sheetReportResult.SetColumnWidth(0, 20 * 256);
sheetReportResult.SetColumnWidth(1, 40 * 256);
sheetReportResult.SetColumnWidth(2, 40 * 256);
var file = new FileStream("C:/ample.xls", FileMode.Create);
workbook.Write(file);
file.Close();
2014年7月3日 星期四
JQuery Div Hide&Show
這段程式碼主要用在DIV顯示跟隱藏
剛好最近在幫客戶家功能,使用GridView做呈現
如果你非常懶的改後端,那就讓前端去幫你處理吧
$('#dvdeatil div').each(function () {
var data = $("#" + this.getAttribute('id')).attr("title");
var county = data ? data.split(",")[0] : ""
switch ($("#<%=ddlcounty.ClientID %>").find(":selected").text()) {
case "全部":
$("#tr_" + this.getAttribute('id')).show();
break;
default:
$("#tr_" + this.getAttribute('id')).show();
if (county != $("#<%=ddlcounty.ClientID %>").find(":selected").text()) {
$("#tr_" + this.getAttribute('id')).hide();
}
break;
}
});
2014年7月2日 星期三
C# XmlDocument &XDocument Interconversion
using System.Xml.Linq;
XmlDocument to XDocument
XmlDocument Xmldoc = new XmlDocument();
XDocument XDoc = XDocument.Parse(Xmldoc.OuterXml);
XDocument to XmlDocument
XDocument Xdoc = new XDocument();
XmlDocument Xmldoc = new XmlDocument();
Xmldoc.LoadXml(Xdoc.Document.ToString());
C# XML To List
最近經常跟Xml當好朋友,要是他能夠變成List<class>那就更好了,下面飯粒
public class UserMessage
{
public string id { get; set; }
public DateTime updated_time { get; set; }
public string snippet { get; set; }
public List<dat> participants { get; set; }
}
public class dat
{
public string name { get; set; }
public string email { get; set; }
public string id { get; set; }
}
List<UserMessage> lma1 = xd1.Descendants("data").Select(d => new UserMessage()
{
id = d.Element("id").Value,
updated_time = Convert.ToDateTime(d.Element("updated_time").Value),
snippet = d.Element("snippet").Value,
participants = d.Descendants("dat").Select(f => new dat()
{
email = f.Element("email").Value,
id = f.Element("id").Value,
name = f.Element("name").Value,
}).ToList().Where(m => m.email != "facebook.com").Select(m => new dat()
{
email = m.email,
id = m.id,
name = m.name,
}).ToList(),
}).ToList();
訂閱:
意見 (Atom)