ASP.NET常识整理

弹出窗口:
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得到字符串变量里面的字符串所占字节数 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值