ASP.NET常用代码

http://tech.ddvip.com   2007年09月02日    社区交流

内容摘要:ASP.NET常用代码

  24.datagrid选定比较底下的行时,为什么总是刷新一下,然后就滚动到了最上面,刚才选定的行因屏幕的关系就看不到了

  page_load

  page.smartNavigation=true

  25.在Datagrid中修改数据,当点击编辑键时,数据出现在文本框中,怎么控制文本框的大小 ?

private void DataGrid1_ItemDataBound(obj sender,DataGridItemEventArgs e)
{
for(int i=0;i<e.Item.Cells.Count-1;i++)
if(e.Item.ItemType==ListItemType.EditType)
{
e.Item.Cells[i].Attributes.Add("Width", "80px")
  
}
}

  26.对话框

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. 将时间格式化:string aa=DateTime.Now.ToString("yyyy年MM月dd日");

  1.1 取当前年月日时分秒

  currentTime=System.DateTime.Now;

作者:周建东    责编:豆豆技术应用

正在加载评论...