ASP.NET常识整理

来源:互联网 发布:农村淘宝绑定有坏处吗 编辑:程序博客网 时间:2024/04/30 21:15

弹出窗口:
Response.Write("<script>window.alert('您已经注册成功!')</script>");
Response.Write("<script>window.top.location='index.aspx'</script>");

如何去掉str后x位字符?只要前面的字符:
string tmp = str.SubString(0,str.Length-x);
如何保留str前i位字符:
string tmp = str.SubString(0,i);
如何去掉str前i位字符:
string tmp = str.SubString(x);
如何去掉str中的abc字符,如果有的话:
string tmp = str.Replace("abc","");

跳出这个if语句用break
跳出函数用return


当返回值是void的时候用return;
当返回值有具体数据类型的时候要返回相应的数据类型。
//跳页
this.Response.Write("<script>window.location.href='contlist.aspx'</script>");
//关闭
this.Response.Write("<script language=javascript>window.close();</script>");
//弹出窗口刷新当前页面width=200 height=200菜单。工具条没有
//this.Response.Write("<script language=javascript>window.open('rows.aspx','newwindow','width=200,height=200')</script>");
//弹出窗口刷新当前页面有菜单。工具条
//Response.Write("<script language=javascript>window.open('rows.aspx')</script>");
//弹出窗口刷新当前页面有菜单。工具条。弹出窗口居中
//Response.Write("<script>window.open('rows.aspx','_blank');</" + "script>");
//弹出窗口刷新当前页面有菜单。工具条。
//this.RegisterStartupScript("OpenNewPage","<script language=javascript>window.open('rows.aspx?ID="+e.ToString()+"','_blank');</script>");
//单点第一页刷新第二页
Response.Write("<script language=javascript>window.opener.location.href=window.opener.location.href</script>"); 
//刷新父关闭当前
Response.Write("<script language='javascript'>window.opener.location.href=window.opener.location.href;window.close();</script>");
Response.Write("<script language='javascript'>window.opener.location.href=window.opener.location.href;window.close();</script>");
this.Response.Write("<script language=javascript>window.open('WebForm3.aspx','newwindow','width=200,height=200,top=200,left=400')</script>");
this.Response.Write("<script language=javascript>window.open('WebForm3.aspx','_blank','width=200,height=200,top=200,left=400');</script>");

ip地址的使用:
string hostIP=System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList[0].ToString();
this.Image1.ImageUrl="http://"+hostIP+"/mtamap/000001.bmp";
//利用主机ip127.0.0.1得到主机名字
IPHostEntry hostInfo=Dns.GetHostByAddress("127.0.0.1");
string hostname=hostInfo.HostName.ToString();
//定位到另一个目录
string url="http://"+hostname+"/mtamap/"+Session["str"].ToString()+".bmp";
this.Response.Redirect(url);
//隐藏菜单栏地址栏工具条的IE,以下变量分别是新窗口的名字,窗口的宽度、高度,有滚动条,窗口距离屏幕上方和左侧的象素  //e.Item.Attributes.Add("onclick","window.open('pdetail.aspx?ID="+e.Item.Cells[1].Text+"','newwin','width=750,height=600,scrollbars=yes,top=50,left=50');");
string s="abc村械地23423";
int byteCount=System.Text.Encoding.Default.GetByteCount(s);
byteCount得到字符串变量里面的字符串所占字节数


 
原创粉丝点击