Trusted Authentication
Data Source=ServerName; Initial Catalog=DatabaseName; Integrated Security=SSPI;
SQL Server Security Authentication
Data Source=ServerName; Initial Catalog=DatabaseName; Integrated Security=SSPI;
$("select#Club").val();
$('select#Club option:selected').text(); 以上2方法在單選時相同,但複選時,
val()會用逗號分開 ex. AA, BB
text()不會 ex. AABB
$("select#Club").children("[@selected]").each(function(){
alert(this.text());
});$("#select1").children().each(function(){
if ($(this).text()=="option you want"){
//jQuery給法
$(this).attr("selected", true); //或是給"selected"也可
//javascript給法
this.selected = true;
}
});var option = jQuery("new option");
$('select#Club').append(option);
$(option).attr("selected","true"); //讓option為selected
$('select#Club').trigger("change"); //最後要觸發select的change事件
$('select#Club')[0].selectedIndex = 1;//不知為何要加[0]=========== K. T. Chen 提到 ==========================
在$("")加[0]的意思是把jQuery物件轉為DOM物件。這樣子jQuery物件才能使用DOM底下的selectedIndex方法。
雖然Form類沒有提供Minimize的事件,但還是可以通過重載Deactive來實現
當Form失去焦點後,測試WindowState取得Form狀態,若為Minimized既是最小化事件。
本例為最小化後隱藏窗口:
private void Form1_Deactivate( object sender, EventArgs e)
{
if ( this .WindowState == FormWindowState.Minimized)
this .Visible = false ; }
const int WM_SYSCOMMAND = 0x112 ;
const int SC_CLOSE = 0xF060 ;
const int SC_MINIMIZE = 0xF020 ;
const int SC_MAXIMIZE = 0xF030 ;
protected override void WndProc( ref Message m)
{
if (m.Msg == WM_SYSCOMMAND)
{
if (m.WParam. ToInt32() == SC_MINIMIZE)
{
this .Visible = false ;
return ; }
}
base .WndProc( ref m); }
此篇文章受密碼保護,請輸入密碼後閱讀。
在 Form Load 中設定 Button1 的 Attributes 屬性:
btnSubmit.Attributes.Add("onclick", "this.disabled=true;" + GetPostBackEventReference(btnSubmit).ToString());
IE7.0 之後 微軟自定義了一些CSS規則,所以變成很多網站常常不明所以出現破版找不到問題,
很大的原因就是相容性檢視設定,在工具列中的工具,選一下相容性檢視設定,常常就海闊天空了,
不用抓table tag抓到抓狂(根本就不是他的錯啊),使用者只會跟你說網站有問題,後端設定一下
,使用者就不用那麼麻煩要自己按那個鬼,保哥的網站有詳細的教學,參考一下吧
寫程式的人大多會用到,主文擷取微軟的MSDN,雖然微軟的MSDN讓許多人視之如廢材,但沒想到用了其他的SAMPLE問題一堆,微軟這個卻寫的還很清楚,修改過後相關寫法如下:
最一開始記得要先引用
using MailMessage=System.Net.Mail.MailMessage;
寄信相關寫法
{
//先取得設定寄件者MAIL與名稱 to 跟 From應該懂吧
MailAddress from = new MailAddress(要寄信的信箱, 寄件者顯示名稱);
MailAddress to = new MailAddress(mailAdd,"");
MailMessage message = new MailMessage(from, to);
//設定主題跟內文
message.Subject = "主旨";
message.Body = "內容";
//做UTF 8編碼 ,可做可不做啦
message.BodyEncoding = Encoding.UTF8;
message.SubjectEncoding = Encoding.UTF8;
//new 一個SMTP SERVER
SmtpClient client = new SmtpClient("你的SmtpServer"));
//設定驗證機制
NetworkCredential pa = new NetworkCredential("你要寄信的信箱帳號","密碼");
client.Credentials = pa;
//寄信
client.Send(message);
}
寄信寫法有多種,如要寄很多信建議用COPY 在CC的方式比較不會被認為大量寄信的垃圾郵件,相關寫法可參照微軟的MSDN,
連結如下:http://msdn.microsoft.com/zh-tw/library/system.net.mail.mailmessage(VS.80).aspx
2.0 才能用喔
簡潔又好用的SQL語法,頂方便的
SELECT 欄位名稱,COUNT(*)/*重複出現的次數*/ FROM member GROUP BY 欄位名稱 HAVING COUNT(*) > 1
/*列出重複出現一次以上的資料*/
最近在寫程式時有用到,主要是因為對方的資料庫不給還原、附加,只他X的給你個SQL 語法介面,要麻你就執行SQL插入,要麻你就等對方幫你匯入,
不過對方說要排隊,所以乾脆自己些產生資料表資料插入語法,引此找了一些特殊的SQL語法:
1.取得資料庫表單數量
select count(*) as totaltablenumber from sysobjects where xtype = 'U';
2.取得資料表名稱(tablename)及欄位數量(columnnumber)
select name as tablename, info as columnnumber from sysobjects where xtype = 'U';
3.取得某一資料表內所有欄位名稱
select b.name from sysobjects as a, syscolumns as b where a.xtype = 'U' and a.id = b.id and a.name='資料表單名稱';