My97DatePicker
Google Chrome
這樣不會運作
<head runat="server">
<title></title>
<link href="../Css/phr-1.2.css" rel="stylesheet" type="text/css" />
<script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
後來試這樣會正常運作,放其他地方也許也可以,有空再試試
<form id="form1" runat="server">
<script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
在chrome測的話,不能是127.0.0.1或http://localhost/會失效
使用MasterPage的話引WdatePicker.js會有路徑錯誤的問題
MasterPage不會轉路徑,但css的會轉,很怪
解決方式:
將<script type="text/javascript" src="<%=ResolveClientUrl("lib/WdatePicker.js")%>"></script>移出<head></head>,個人是放在</html>後(適用不是一開始就要執行的javascript)。
有ResolveClientUrl跟ResolveUrl ,下次遇見不行再試另一個
測試文字功能,小工具,標題
記錄很重要,不然會浪費很多時間在找以前的記憶
一個人的氣度,決定他未來的高度。
2015年1月5日 星期一
2015年1月4日 星期日
ASP.NET Drawing.Color
Drawing.Color
e.Row.Cells[8].ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFFCC");
e.Row.Cells[8].ForeColor = System.Drawing.Color.Red;
C# Color Name Table
http://www.flounder.com/csharp_color_table.htm
e.Row.Cells[8].ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFFCC");
e.Row.Cells[8].ForeColor = System.Drawing.Color.Red;
C# Color Name Table
http://www.flounder.com/csharp_color_table.htm
2014年12月29日 星期一
2014年9月23日 星期二
2014年7月22日 星期二
T-SQL 自己常用的一語法
直接用自己的欄位更新資料
從key抓前7碼丟回去dataf,欄位去更新完SUBSTRING(dataf,18,7),條件是原本SUBSTRING(dataf,18,7)='0000000'+上另一個條件,
--UPDATE modre
--SET dataf=SUBSTRING(dataf,1,17)+SUBSTRING(key,1,7)+SUBSTRING(key,1,7)+SUBSTRING(dataf,32,datalength(dataf)-31)
--WHERE key>='1070701000101'
--and key < '1070801000101'
--AND SUBSTRING(data,1,5)='01038'
--and SUBSTRING(dataf,18,7)='0000000'
===================================================
計算ip次數,ip > 10 ,再排序
SELECT ip, COUNT(IP) as new_count_ip
FROM [dbo].[123RegLog]
GROUP BY ip
HAVING COUNT(IP) > 10
order by new_count_ip desc;
計算ip次數,ip > 10,ip <> '',指定日期
SELECT IP,COUNT(IP) as new_count_ip
FROM [dbo].[123RLog]
where ldate >= '2015-05-28'
GROUP BY ip
HAVING COUNT(IP) > 10
AND ip <> ''
從key抓前7碼丟回去dataf,欄位去更新完SUBSTRING(dataf,18,7),條件是原本SUBSTRING(dataf,18,7)='0000000'+上另一個條件,
--UPDATE modre
--SET dataf=SUBSTRING(dataf,1,17)+SUBSTRING(key,1,7)+SUBSTRING(key,1,7)+SUBSTRING(dataf,32,datalength(dataf)-31)
--WHERE key>='1070701000101'
--and key < '1070801000101'
--AND SUBSTRING(data,1,5)='01038'
--and SUBSTRING(dataf,18,7)='0000000'
===================================================
計算ip次數,ip > 10 ,再排序
SELECT ip, COUNT(IP) as new_count_ip
FROM [dbo].[123RegLog]
GROUP BY ip
HAVING COUNT(IP) > 10
order by new_count_ip desc;
計算ip次數,ip > 10,ip <> '',指定日期
SELECT IP,COUNT(IP) as new_count_ip
FROM [dbo].[123RLog]
where ldate >= '2015-05-28'
GROUP BY ip
HAVING COUNT(IP) > 10
AND ip <> ''
2014年7月6日 星期日
ASP.NET GridView 自己常用的記錄
增加一個按鈕
1.可以用RowCommand事件,不用另外在RowDataBound用e.Row.Attributes另外加事件上去
protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName != "SendMail") return;
int id = Convert.ToInt32(e.CommandArgument);
// do something
}
2.另一種自己寫事件 例如BtnUp_Click
Button btn = (Button)sender;
GridViewRow gvr = (GridViewRow)btn.NamingContainer;
string str_emp_id = gvr.Cells[0].Text;
抓row index 用 gvr.Rowindex
使用Template的特定控制項:gvr.FindControl("Button1");
註 : AutoGenerateColumns="false" Bind後欄位不自動增加
註 : ItemStyle-HorizontalAlign="Center" 文字置中
註 : DataItemIndex等於Binding中的絕對index
由後台餵資料,資料欄位要包含DataField會自動
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_OnRowCommand" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="email" HeaderText="Email" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="SendMail"
Text="SendMail" CommandArgument='<%# Eval("id") %>' OnClick="BtnUp_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
================================================
RowDataBound
e.Row.Cells[0].Attributes["onclick"] = "if (!confirm('確 定 要 歸 還 設 備 嗎?')) { return false; };" + this.Page.ClientScript.GetPostBackEventReference((GridView)sender, "Del$" + e.Row.Cells[0].Text);
================================================
點選GridView後回到TOP MaintainScrollPositionOnPostback="false"
在ASPX的最上面那行,如果要保持在點選的位置時就改true
<%@ Page Title="" Language="C#" MasterPageFile="~/it_mg/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" MaintainScrollPositionOnPostback="false" CodeFile="Default.aspx.cs" Inherits="it_mg_pc_data_Default" %>
========================================================
注意事項 GridView生命週期
要注意,動態加入Control控制項在RowDataBound跟RowCreated的執行,有所不同
要去看一下GridView生命週期
========================================================
抓GridView的值
String strmsg = this.GridView1.Rows[0].Cells[0].Text;
1.可以用RowCommand事件,不用另外在RowDataBound用e.Row.Attributes另外加事件上去
protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName != "SendMail") return;
int id = Convert.ToInt32(e.CommandArgument);
// do something
}
2.另一種自己寫事件 例如BtnUp_Click
Button btn = (Button)sender;
GridViewRow gvr = (GridViewRow)btn.NamingContainer;
string str_emp_id = gvr.Cells[0].Text;
抓row index 用 gvr.Rowindex
使用Template的特定控制項:gvr.FindControl("Button1");
註 : AutoGenerateColumns="false" Bind後欄位不自動增加
註 : ItemStyle-HorizontalAlign="Center" 文字置中
註 : DataItemIndex等於Binding中的絕對index
由後台餵資料,資料欄位要包含DataField會自動
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_OnRowCommand" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="email" HeaderText="Email" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="SendMail"
Text="SendMail" CommandArgument='<%# Eval("id") %>' OnClick="BtnUp_Click" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
================================================
RowDataBound
e.Row.Cells[0].Attributes["onclick"] = "if (!confirm('確 定 要 歸 還 設 備 嗎?')) { return false; };" + this.Page.ClientScript.GetPostBackEventReference((GridView)sender, "Del$" + e.Row.Cells[0].Text);
整個Row
e.Row.Attributes["onclick"] = "if (!confirm('確 定 要 歸 還 設 備 嗎?')) { return false; };" + this.Page.ClientScript.GetPostBackEventReference((GridView)sender, "Del$" + e.Row.Cells[0].Text);
================================================
點選GridView後回到TOP MaintainScrollPositionOnPostback="false"
在ASPX的最上面那行,如果要保持在點選的位置時就改true
<%@ Page Title="" Language="C#" MasterPageFile="~/it_mg/MasterPage.master" AutoEventWireup="true" EnableEventValidation="false" MaintainScrollPositionOnPostback="false" CodeFile="Default.aspx.cs" Inherits="it_mg_pc_data_Default" %>
========================================================
注意事項 GridView生命週期
要注意,動態加入Control控制項在RowDataBound跟RowCreated的執行,有所不同
要去看一下GridView生命週期
========================================================
抓GridView的值
String strmsg = this.GridView1.Rows[0].Cells[0].Text;
訂閱:
文章 (Atom)