嗨,我正致力于项目拼图益智游戏。我已经完成了使用vb脚本在经典asp中编码并且它正常工作。我想用vb.net做同样的asp.net编码,但css样式我写的它在asp.net中无法正常工作,任何人都可以帮我做这个转换。
<html>
<head>
<script type="text/javascript">
function setText(pieceID)
{
if (document.getElementById("first").value == '' )
{
document.getElementById("first").value=pieceID;
}
else
{
document.getElementById("second").value=pieceID;
document.swap.submit();
}
}
</script>
</head>
<body>
<%
dim img
img = "img1.jpg"
%>
<div class="classname"> <img src="<%response.write img%>"> </div>
<%dim imgPIX
imgPIX = 60
%>
<style>
.icons { display: block; width: <%response.write imgPIX%>px; height: <%response.write imgPIX%>px; background-image: url(<%response.write img%>); background-repeat: no-repeat; }
<%
dim proper
dim ico_number,col
dim row_number,rw
for row_number = 1 to 6
rw = (row_number - 1) * (-1 * imgPIX)
for ico_number = 1 to 6
col = (ico_number - 1) *(-1 * imgPIX)
response.write ".icon"& row_number &"_"& ico_number &" { background-position: col &"px "& rw &"px; } "
if not proper = "" then
proper = proper & "," & row_number &"_"& ico_number
else
proper = row_number &"_"& ico_number
end if
response.write ".icon"& row_number &"_"& ico_number &" { background-position: 0px 0px; } "
next
next
%>
</style>
<%
dim userfeed
if request.form("userform") = "" then
userfeed = random_sort(proper)
end if
if request.form("first") <> "" and request.form("second") <> "" then
userfeed = request.form("userform")
userfeed = replace(userfeed,request.form("first"),"temp1")
userfeed = replace(userfeed,request.form("second"),"temp2")
userfeed = replace(userfeed,"temp1",request.form("second"))
userfeed = replace(userfeed,"temp2",request.form("first"))
end if
%>
<center>
<form name="swap" action="default.asp" method="post">
<input type="hidden" name="first" ID="first">
<input type="hidden" name="second" ID="second">
<input type="hidden" name="userform" ID="userform" value="<%response.write userfeed%>">
</form>
<table border="0">
<%
if userfeed = proper then
%>
<H1>Solved !!</h1>
<%
end if
dim icoarr
icoarr = split(userfeed,",")
dim ctr
ctr =0
for each piece in icoarr
if ctr =6 then
response.write "<tr>"
end if
%>
<td><span class="icons icon<%response.write piece%>" style="float:left;" onclick="setText('<%response.write piece%>')"></span></td>
<%
if ctr =6 then
ctr =1
else
ctr = ctr + 1
end if
next
%>
<%public function random_sort(arrySTR)
arrySTR = arrySTR & ","
dim retstr
do while arrySTR <> ""
dim arr
arr = split(arrySTR,",")
dim random_number
randomize
random_number=int(rnd*(ubound(arr)-1))+0
'response.write random_number
retstr =arr(random_number) & "," & retstr
arrySTR = replace(arrySTR,arr(random_number) & ",","")
loop
retstr = mid(retstr,1,len(retstr)-1)
'response.write "<br>" & retstr
random_sort=retstr
end function
%>
</table>
</body>