基于ASP的Web开发中常用代码

<!--使表格带有连接功能--->
<html>
<head>
<title>HTML document</title>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" width="200" height="200" bgcolor="Gray"><tr><td οnmοuseοver=this.bgColor="#800000" οnclick=window.location.href="http://www.google.com">google</td></tr><tr><td οnmοuseοver=this.bgColor="#008000" οnclick=window.location.href="http://www.blueidea.com">bluidea.c ... 0" οnclick=window.location.href="http://www.blueidea.com/bbs">bbs</td></tr></table>
</body>
</html>


<%
'获取URL值,跳转到新网址
dim a,b
a=request.querystring("boardID")
b=request.querystring("id")
response.redirect("http://bbs.anquan.com.cn/dispbbs.asp?boardid ... "&id="&b)
%>

<%@ Language=VBScript %>
<html>
<title>No.2根据远程主机地址来进行判断,如果为本地地址则进入欢迎页面,否则显示出错信息.</title>
<body>

本地ip
<%=Request.ServerVariables("REMOTE_ADDR")%>
服务器IP
<%=Request.ServerVariables("LOCAL_ADDR")%>
<%
dim address
address = request.servervariables("REMOTE_ADDR")
response.write address
if address="127.0.0.1" then
'如果为本地,则显示欢迎页面.
response.write "你好,欢迎进入本站点."
'response.redirect "http://localhost/100asp/001.asp"
else
'否则显示出错信息.
response.write "对不起,你无权查看内部站点."
end if
%>
</body>
</html>

'按时间判断,显示最新标志
<%
mytime=rs("time") '数据库中保存时间
nowtime=now() '当前时间
if datediff("d",mytime,nowtime)<1 then
'比较当前时间和数据库中时间,如相差小于1,即显示图片new.gif
%>
<img src="images/new.gif">
<%end if%>


'图片大时,自动缩小的写法.
<img border="0" src="<%=trs("e_simg")%>" οnlοad="javascript:if(this.width>120)this.width=120" alt="<%=trs("e_trem")%>">

'几个条件语句的写法
while ...........wend
do while .................loop
有判断是
if........else end if
if........elseif end if

'长标题截取的写法1
<% if len(rs("showname"))>13 then%>
<%=left(rs("showname"),12)%>..
<% else%>
<%=rs("showname")%>
<%end if%>
'写法2
<%if len(rs("quizTitle"))>13 then response.write left(rs("quizTitle"),12)&".." else response.write rs("quizTitle") end if%>

'出错或完成操作后提示语句.
<%
response.write "<script language=javascript>alert('请留言!');window.location.href='liuyan.asp';</script>"
%>
<%
response.write "<script language=JavaScript>" & chr(13) & "alert('请检查您填写的内容是否完整!');" & "history.back()" & "</script>"
%>


'把表中有限的几个分类转换成"汉字"
<%
dim quizClass,quizOption
'quizClass=rs("quizLib.quizClass")
quizClass=rs("quizClass")
select case quizClass
case "radio1"
response.Write("判断题")
case "radio2"
response.Write("单选题")
case "checkbox"
response.Write("多选题")
case "text"
response.Write("填空题")
end select
%>

'确定删除一条记录
<a href="del.asp?info_id=<%=rs("info_id")%>" οnclick=return(confirm("确定要删除第<%=rs("info_id")%>条记录吗?"))>删除</a>

'动态显示下拉菜单
'如果记录集为空就指向主页
'value值为表subject中的ID
<select name="booktype" class="button1" id="booktype" style="width:250">
<option value=all selected>试题学科</option>
<%
sql="SELECT * FROM subject"
set rs=conn.execute(sql)
if rs.bof or rs.eof then response.Redirect("index.asp")
while not(rs.bof or rs.eof)
response.Write "<option value="&rs("id")&">"&rs("subjName")&"</option>"
rs.movenext
wend
%>
</select>

'获取数据库里的
<select name="mem_sex" id="mem_sex">
<option value="男" <%if rs("mem_sex")="男" then response.write "selected"%>>男</option>
<option value="女" <%if rs("mem_sex")="女" then response.write "selected"%>>女</option>
</select>
<!--限制文本框不能输入空格-->
<script language="javascript">
function id_keyup(txtinput)
{
txtinput.value=txtinput.value.replace(/(^/s*)|(/s*$)/g, "");
}
</script>
<input type="text" name="id" οnkeyup="id_keyup(this)">


9.随机背景音乐:
<%randomize%>
<bgsound src="mids/<%=(int(rnd()*60)+1)%>.mid" loop="-1">

可以修改数字,限制调用个数,我这里是60个.

状态栏文字的显示,这个简单实用!
<BASE οnmοuseοver="window.status='欢迎光临!-我的邮件:mxsky{at}126.com';return true">

打开的一个迷你窗口

『复制代码』『运行代码』

<script language="javascript">
function mini_window(page,w,h)
//打开一个小窗口
/*
page 页面名称
w 宽度
h  高度
*/
{
var arr = showModalDialog(page, "", "dialogWidth:"+w+"px; dialogHeight:"+h+"px; status:0;help:0");
}
//打开一个小窗口
</script>
<body style="overflow:scroll;overflow-x:hidden;overflow-y:hidden">
<a style=cursor:hand ; οnclick=mini_window('default.asp','650','515')>打开新窗口</a>
</body>


加标题的电子邮件:
<a href="mailto:admin@anquan.com.cn?subject=关于考试系统的问题">flashboy</a>

iframe调用时如何让背景透明
<Iframe src="transparent.htm" allowtransparency="true"></Iframe>
transparent.htm
<body style="background-color:transparent">


按钮在原窗口打开
<input type="button" name="button2" value="注册" οnclick="location.href='http://www.google.com'">

按钮在新窗口打开
<input type="button" name="button2" value="注册" οnclick="window.open('http://www.google.com')">

让英文字符串超出表格宽度自动换行
<td style="word-wrap:break-word; word-break:break-all;">

永远都会带着框架
<script language="JavaScript">
<!--
if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页
// -->
</script>

防止被人frame
<SCRIPT LANGUAGE=JAVASCRIPT>
<!--
if (top.location != self.location)top.location=self.location;
// -->
</SCRIPT>

网页将不能被另存为
<noscript><iframe src=*.html></iframe></noscript>

删除时确认
<a href='javascript:if(confirm("确实要删除吗?"))location="del.asp"'>删除</a>

不要滚动条
让竖条没有:
<body style='overflow:scroll;overflow-y:hidden'>
</body>
让横条没有:
<body style='overflow:scroll;overflow-x:hidden'>
</body>
两个都去掉?更简单了:
<body scroll="no">
</body>

鼠标划过,表格变色
<tr οnmοuseοver="this.bgColor='red'" οnmοuseοut="this.bgColor=''">

屏蔽右键
<body οncοntextmenu="return false;">

<script language="JavaScript">
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>


用正则强制输入数字
<input name="id2" type="text" οnkeyup='this.value=this.value.replace(//D/gi,"")'>

禁止输入中文
<input type=text style="ime-mode: disabled ">

不允许文本框自动完成
<input autocomplete=off>

图片变灰,掠过恢复
<img src="http://community.csdn.net/images/csdn.gif" style="filter:gray" onmo ... useout="this.style.filter='gray'">

定时跳转到其它页面
<meta http-equiv="refresh" content="5;URL=http://54caizi.com">

TITLE换行
<a href=# title="第一行第二行第三行">title分行测试</a>

行背景色渐变
<table width="100%" height="100%">
<tr><td style="FILTER: progid:DXImageTransform.Microsoft.Gradient(endColorstr='#EFF3FF', startColorstr='#94B2F7', gradientType='1')" ></td></tr>
</table>
说明:
功能从startcolorstr渐变到endcolorstr
gardientType 是填充样式,具体值请自己尝试

调用其它页面
<object type="text/x-scriptlet" width="800" height="1000" data="a.htm"></object>

Iframe的常用用法
<iframe WIDTH=100% HEIGHT=240 MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 allowTransparency="true" SCROLLING=no SRC='Cay/blog.asp'></iframe>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
基于 ASP.NET 的管理系统可以利用以下一些关键技术和工具: 1. ASP.NET Web Forms:ASP.NET Web Forms 是一种使用类似于 Windows 窗体的开发模型来构建 Web 应用程序的技术。它提供了一组丰富的服务器控件和事件模型,可用于构建交互式的用户界面。 2. ASP.NET MVC:ASP.NET MVC(Model-View-Controller)是一种基于模型、视图和控制器的开发模式,可以帮助开发人员实现良好的代码分离和更好的应用程序可测试性。 3. C#:C# 是 ASP.NET 的主要编程语言,它是一种面向对象的编程语言,提供了强大的功能和丰富的类库,可用于开发 ASP.NET 应用程序。 4. 数据库:管理系统通常需要与数据库进行数据交互和存储。ASP.NET 提供了与多种数据库(如 Microsoft SQL Server、MySQL、Oracle 等)进行集成的功能。您可以使用 ADO.NET、Entity Framework 或 LINQ 等技术来访问和操作数据库。 5. HTML/CSS/JavaScript:前端技术是开发管理系统不可或缺的一部分。HTML 用于定义网页结构,CSS 用于样式设计,JavaScript 用于实现交互性和动态效果。 6. 安全性:管理系统通常需要考虑用户认证、授权和数据安全等问题。ASP.NET 提供了一系列的安全性功能,如身份验证和授权机制、加密和防范常见攻击等。 7. Visual Studio:Visual Studio 是一个强大的集成开发环境(IDE),它提供了丰富的工具和功能,可用于开发、调试和部署 ASP.NET 应用程序。 以上是基于 ASP.NET 管理系统常用的一些关键技术和工具,根据具体需求和项目规模,您还可以结合其他技术和框架来实现更多功能和增强系统性能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

UniMagic

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值