原程式網頁的網頁點我
但如果是連動例如DropDownList1連動DropDownList2就必需要用jquery live(邊學邊做系列有教大家可以去看看)
好像要jQuery 1.3.2版後才有這功能喔
////// 判斷是否為數字 /// /// 傳入判斷的字串。 public static bool IsNumeric(String pNumber) { Regex NumberPattern = new Regex("[^0-9.-]"); return !NumberPattern.IsMatch(pNumber); } ////// 三位一撇 + 小數??位 /// /// 傳入字串數字。 /// 傳入字串。 public static string ToThree(string pInt,string p0) { string mReturn = string.Empty; if (pInt != "") { if (IsNumeric(pInt)) { mReturn = string.Format("{0:N"+ p0+"}", Convert.ToDecimal(pInt)); } } else { mReturn = string.Format("{0:N" + p0 + "}", "0"); } return mReturn; }
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('完成');opener.location.reload();window.close();", true);
protected void Button1_Click(object sender, EventArgs e) { Response.Clear(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); //內容自行新增 string fileName = DropDownList1.SelectedValue.ToString() + DropDownList1.SelectedValue.ToString()+ ".xls"; if (Request.Browser.Browser == "IE") { fileName = Server.UrlPathEncode(fileName); } string style = " "; Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName ); //Response.Write(""); Response.ContentType = "application/ms-excel"; Response.ContentEncoding = System.Text.Encoding.Default;//.Unicode;//.UTF8;// System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); //文字格式處理 Response.Write(style); Response.Write(sb.ToString());//內容 Response.Write(stringWrite.ToString()); Response.End(); } 以下這段一定要加 public override void VerifyRenderingInServerForm(Control control) { //處理'GridView' 的控制項 'GridView' 必須置於有 runat=server 的表單標記之中 }ps如放在button放在updatepanel裡
update StatementList set CX_Less_Money = (CX_Total - ( select SUM( CONVERT(Decimal, CX_Amount ) ) from StatementItem where ID_Statement=@ID_Statement)) where ID_Statement =@ID_Statement
////// 回傳數字Decimal,非數字及空白都變成0 /// /// 傳入字串。 public static Decimal ToDecimal(string pInt) { Decimal mReturn = 0; if (pInt == "") { mReturn = 0; } else { if (IsNumeric(pInt)) { mReturn = Convert.ToDecimal(pInt); } else { mReturn = 0; } } return mReturn; } var QueryA =( from u in dt1.AsEnumerable() group u by new { CX_Size = u["CX_Size"], CX_Color_Name = u["CX_Color_Name"] } into g select new { CX_Size = g.Key.CX_Size, CX_Color_Name = g.Key.CX_Color_Name, CX_Quantity = g.Sum(p => Convert.ToDecimal(PublicClass.ToDecimal(p["CX_Quantity"].ToString()))), CX_Amount = g.Sum(p => Convert.ToDecimal(PublicClass.ToDecimal(p["CX_Amount"].ToString()))) }).ToList(); 最後再用迴圈來統計 foreach (var mRowA in QueryA) { //做處理 }
//取得流水號
string Sql1 = " select top 1 convert(int,substring(CX_Order_No,6,3)) as maxNo from QuoteList where substring(CX_Order_No,1,5)=@yyyMM order by convert(int,substring(CX_Order_No,6,3)) desc ";
SqlCommand cmd1 = new SqlCommand(Sql1, conn);
decimal myyy = PublicClass.ToDecimal(DateTime.Now.Year.ToString() )- 1911;
myyyyMM = myyy.ToString() + int.Parse(DateTime.Now.Month.ToString()).ToString("00");
cmd1.Parameters.AddWithValue("@yyyMM", myyyyMM);
DataTable dt1 = new DataTable();
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
myyyyMM = myyyyMM + int.Parse( ( PublicClass.ToDecimal(dt1.Rows[0]["maxNo"].ToString()) + 1).ToString()).ToString("000");//有時給他加1
}
else
{
myyyyMM = myyyyMM + "001";//沒有時就給他001
}
string test = int.Parse(DateTime.Now.Month.ToString()).ToString("00"); string test = string.Format("{0:00}", Convert.ToInt16(mNow.Month));
protected void AJaxShowMessage(string Message) { string scriptA = string.Empty; string messageA = string.Empty; messageA = Message.Replace("'", "\\"); messageA = messageA.Replace("\r\n", "\\n"); scriptA = string.Format("alert('{0}');", messageA); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", scriptA, true); }
using System.Text.RegularExpressions;//導入命名空間(正規表達式)
/// <summary>
/// 判斷是否為日期
/// </summary>
/// <param name="pDate">傳入字串。</param>
public static bool IsDate(string pDate)
{
return Regex.IsMatch(pDate, @"^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-9]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$");
}
/// <summary>
/// 判斷是否為時間
/// </summary>
/// <param name="pTime">傳入字串。</param>
public static bool IsTime(string pTime)
{
return Regex.IsMatch(pTime, @"^((20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$");
}
/// <summary>
/// 判斷是否日期+時間
/// </summary>
/// <param name="pDateTime"></param>
public static bool IsDateTime(string pDateTime)
{
return Regex.IsMatch(pDateTime, @"^(((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-)) (20|21|22|23|[0-1]?\d):[0-5]?\d:[0-5]?\d)$ ");
}
/// <summary>
/// 回傳yyyy/MM/dd
/// </summary>
/// <param name="pDate">傳入字串。</param>
public static string ToyyyyMMdd(string pDate)
{
string mReturn = string.Empty;
if (pDate != "")
{
mReturn = DateTime.Parse(pDate).ToString("yyyy/MM/dd");
}
return mReturn;
}
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network defaultCredentials="false" host="msa.hinet.net" port="25"/>
</smtp>
</mailSettings>
</system.net>
<abc@gmail.com> ,<def@gmail.com> ,
PublicClass Class = new PublicClass();//假如這function放在PublicClass裡時
Class.SendByMail(收件人,標題,內文, 寄件人會顯示的標題, 寄件的Email);
/// <summary>
/// 用Client寄信 需New出來
/// </summary>
/// <param name="pMail">收件者可以,分格寄多人</param>
/// <param name="pSubject">信件標題</param>
/// <param name="pBody">信件內容</param>
/// <param name="pFromMailName">寄件人會顯示的標題</param>
/// <param name="pFromMail">寄件的Email</param>
public void SendByMail(string pMail, string pSubject, string pBody, string pFromMailName, string pFromMail)
{
System.Net.Mail.MailMessage Mail = new System.Net.Mail.MailMessage();
Mail.From = new System.Net.Mail.MailAddress(pFromMail, pFromMailName);
Mail.Subject = pSubject;
Mail.IsBodyHtml = true;
Mail.BodyEncoding = System.Text.Encoding.UTF8;
Mail.SubjectEncoding = System.Text.Encoding.UTF8;
Mail.Body = pBody;
//這邊多人可以回圈
char[] delimiterChars = { ',' };
string[] words = pMail.Split(delimiterChars);
foreach (string s in words)
{
if (s.Trim() != "")
{
Mail.To.Add(s);
}
}
System.Net.Mail.SmtpClient SMTPServer = new System.Net.Mail.SmtpClient(System.Web.Configuration.WebConfigurationManager.AppSettings["SmtpHost"]);
SMTPServer.Send(Mail);
System.Threading.Thread.Sleep(5);
GC.Collect();
GC.WaitForPendingFinalizers();
}
string mStr = string.Join(",", mStr.Split(',').Distinct().ToArray());
/// <summary>
/// 查產品
/// </summary>
/// <param name="pTitle)">產品名稱</param>
public static DataTable GetPoducts(string pTitle)
{
DataTable dt = new DataTable();
using (SqlConnection conn = new SqlConnection(ConnectionString()))
{
string Sql = "select * from Products where 1 = 1 and Title=@Title";
SqlCommand cmd = new SqlCommand(Sql, conn);
cmd.Parameters.Add("@Title", SqlDbType.VarChar).Value = "%" + pTitle + "%";
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
cmd.Dispose();
da.Dispose();
}
return dt;
}
using System.IO; using System.Drawing; /// <summary>
/// 將 Image 轉換為 Byte 陣列。 /// </summary>
/// <param name="ImgPath">圖片路徑 。</param> public byte[] ImageToBuffer(string ImgPath) { byte[] _ImageBytes;
if (File.Exists(ImgPath)) {
Image _Image = Image.FromFile(ImgPath); MemoryStream ms = new MemoryStream(); _Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); _ImageBytes = ms.GetBuffer(); ms.Dispose(); _Image.Dispose(); } else { _ImageBytes = null; } return _ImageBytes; }
using System.Text.RegularExpressions;//導入命名空間(正規表達式)
/// <summary>
/// 判斷是否為數字
/// </summary>
/// <param name="pNumber">傳入判斷的字串。</param>
public static bool IsNumeric(String pNumber)
{
Regex NumberPattern = new Regex("[^0-9.-]");
return !NumberPattern.IsMatch(pNumber);
}
insert into abc ( ProductsName )
VALUES (ProductsName )
;SELECT @@IDENTITY;
<system.web>
<!-- 最大上傳檔案大小100MB(100*1024) TimeOut時間300秒 -->
<httpRuntime maxRequestLength="102400" executionTimeout="300"/>
</system.web>
string Path = Server.MapPath("txt/abcd.txt");//檔案路徑 using (StreamReader sr = File.OpenText(Path)) { String input; while ((input = sr.ReadLine()) != null) { //input如果不是null的話就會是一行文字 //做處理 } }
h3 class='post-title
<script>
document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=<data:post.url/>&layout=standard&show_faces=true&width=450&action=like&font=verdana&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:20px"></iframe>');
</script>
<b:includable id='comments' var='post'>
<div id='fb-root'/><script src='http://connect.facebook.net/zh_TW/all.js#appId=appid&xfbml=1'/><fb:comments expr:href='data:post.url' num_posts='2' width='500'/>
$(function () {
tb_init('a.thickbox, area.thickbox, input.thickbox');
imgLoader = new Image(); // preload image
imgLoader.src = tb_pathToImage;
});
function pageLoad(sender, args) {
tb_init('a.thickbox, area.thickbox, input.thickbox');
imgLoader = new Image(); // preload image
imgLoader.src = tb_pathToImage;
}
function tb_init(domChunk){
$(domChunk).click(function(){
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
tb_show(t,a,g);
this.blur();
return false;
});
}
function tb_init(domChunk) {
$(domChunk).click(function() {
var t = this.title || this.name || null;
var a = this.href || this.alt;
var g = this.rel || false;
self.parent.tb_show(t, a, g);
this.blur();
return false;
});
}
<asp:literal id="Literal1" runat="server"></asp:literal>
string mUrl = Request.Url.AbsoluteUri;// 取得目前網址
Literal1.Text = string.Format("<img alt="簡單使用" src="https://chart.googleapis.com/chart?chs=120x120&cht=qr&chl={0}&choe=UTF-8&chld=M|2">", mUrl);
<script type="text/javascript">
function wopen(word) {
window.open('http://www.google.com/#hl=zh-TW&source=hp&q=' + word, 'Google');
}
</script>
<input class="submit" onclick="wopen(this.form.text.value);return true;" type="submit" value="Google搜尋">
<input id="text" name="keyword" type="text">
CKEDITOR.editorConfig = function(config) {
config.font_names = 'Arial;Arial Black;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana;新細明體;細明體;標楷體;微軟正黑體';
}
CKEDITOR.editorConfig = function(config) {
config.toolbar = 'MyToolbar';
config.toolbar_MyToolbar =
[
['Source', 'Preview', '-'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
['Link', 'Unlink', 'Anchor'],
['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
['Styles', 'Format', 'Font', 'FontSize'],
['TextColor', 'BGColor'],
['Maximize', 'ShowBlocks']
];
}
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove()", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();var win = top.window; try{ if(win){ win.location.reload(); } }catch(ex){} ;", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();parent.myiframe.location.reload();", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();parent.document.getElementById('" + Request.QueryString["s"].ToString() + "').value=1;parent.document.getElementById('" + Request.QueryString["b"].ToString() + "').click(); ", true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.tb_remove();var win = top.window; try{ if(win){ win.location.href='code.aspx'; } }catch(ex){};", true);
<input type="button" value="Detail" style="text-align: center;" onclick="tb_show('Detail','_Statement.aspx?type=modify&id=<%# Eval("ID_Statement") %>&b=<%# this.Button2.ClientID %>&s=<%# this.HiddenFieldStatus.ClientID %>&KeepThis=true&TB_iframe=true&height=550&width=750',null);" />
ScriptManager.RegisterStartupScript(this, this.GetType(), "提示訊息", "alert('完成');parent.document.getElementById('" + Request.QueryString["s"].ToString() + "').value=1;parent.document.getElementById('" + Request.QueryString["b"].ToString() + "').click(); ", true);
////// 去除Html標籤 /// /// 傳入一整個Ckeidtor文字。 public static string ReplaceHtmlTag(string Html) { Html = Regex.Replace(Html, "<[^>]*>", ""); return Html; }