ASP.NET中常用的三十三種代碼第6/7頁
更新時(shí)間:2007年03月25日 00:00:00 作者:
26.對(duì)話框
private static string ScriptBegin = "<script language=\"JavaScript\">";
private static string ScriptEnd = "</script>";
public static void ConfirmMessageBox(string PageTarget,string Content)
{
string ConfirmContent="var retValue=window.confirm('"+Content+"');"+"if(retValue){window.location='"+PageTarget+"';}";
ConfirmContent=ScriptBegin + ConfirmContent + ScriptEnd;
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm",ConfirmContent);
//Response.Write(strScript);
}
27. 將時(shí)間格式化:string aa=DateTime.Now.ToString("yyyy年MM月dd日");
1.1 取當(dāng)前年月日時(shí)分秒
currentTime=System.DateTime.Now;
1.2 取當(dāng)前年
int 年= DateTime.Now.Year;
1.3 取當(dāng)前月
int 月= DateTime.Now.Month;
1.4 取當(dāng)前日
int 日= DateTime.Now.Day;
1.5 取當(dāng)前時(shí)
int 時(shí)= DateTime.Now.Hour;
1.6 取當(dāng)前分
int 分= DateTime.Now.Minute;
1.7 取當(dāng)前秒
int 秒= DateTime.Now.Second;
1.8 取當(dāng)前毫秒
int 毫秒= DateTime.Now.Millisecond;
28.自定義分頁代碼:
先定義變量 :
public static int pageCount; //總頁面數(shù)
public static int curPageIndex=1; //當(dāng)前頁面
下一頁:
if(DataGrid1.CurrentPageIndex < (DataGrid1.PageCount - 1))
{
DataGrid1.CurrentPageIndex += 1;
curPageIndex+=1;
}
bind(); // DataGrid1數(shù)據(jù)綁定函數(shù)
上一頁:
if(DataGrid1.CurrentPageIndex >0)
{
DataGrid1.CurrentPageIndex += 1;
curPageIndex-=1;
}
bind(); // DataGrid1數(shù)據(jù)綁定函數(shù)
直接頁面跳轉(zhuǎn):
int a=int.Parse(JumpPage.Value.Trim());//JumpPage.Value.Trim()為跳轉(zhuǎn)值
if(a<DataGrid1.PageCount)
{
this.DataGrid1.CurrentPageIndex=a;
}
bind();
相關(guān)文章
asp.net 根據(jù)漢字的拼音首字母搜索數(shù)據(jù)庫(附 LINQ 調(diào)用方法)
我們經(jīng)常需要使用拼音首字母來檢索數(shù)據(jù)庫,特別是應(yīng)用于醫(yī)院、商店等行業(yè)軟件中。譬如搜索“zgr”就可以搜索所有包含“中國人”的記錄。那么如果來實(shí)現(xiàn)才能即高效又方便呢?2010-04-04
在Asp.net core項(xiàng)目中使用WebSocket
這篇文章介紹了在Asp.net core項(xiàng)目中使用WebSocket的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-08-08
使用母版頁時(shí)內(nèi)容頁如何使用css和javascript
由于網(wǎng)站的主要頻道頁和列表頁的頭部和底部都是一樣的,如果將每個(gè)頁面放在單獨(dú)的頁面中,當(dāng)頭部和底部需要更改時(shí)維護(hù)量太大。于是想把頭部和底部做成母版頁,頻道頁和列表頁的具體內(nèi)容放到內(nèi)容頁中。這樣當(dāng)頭和底需要改動(dòng)時(shí),只要修改一下母版頁就可以了。2009-08-08
ASP.NET Core使用AutoMapper實(shí)現(xiàn)實(shí)體映射
本文詳細(xì)講解了ASP.NET Core使用AutoMapper實(shí)現(xiàn)實(shí)體映射的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-03-03
.net c# gif動(dòng)畫如何添加圖片水印實(shí)現(xiàn)思路及代碼
本文將詳細(xì)介紹下c#實(shí)現(xiàn)gif動(dòng)畫添加圖片水印,思路很清晰,感興趣的你可以參考下哈,希望可以幫助到你2013-03-03

