日期:2014-05-20  浏览次数:20396 次

[VB]我想用这么一段在ASP中借过来的程序,可是出错?怎么办呢?
在ASP中
function   SayErr(err_str,str1)
response.write   " <script   language=javascript> "
if   err_str <> " "   then
response.write   "alert( ' "&err_str& " '); "
end   if
if   trim(str1)= " "   then
response.write   "if(history.length==0){opener= 'kingneed ';window.close()}else{history.back();} </script> "
else
response.write   "location= ' "&str1& " '; </script> "
end   if
response.end
end   function
是可以运行的
但是我在.NET中改成这样
function   SayErr(err_str,str1)
response.write( " <script   language=javascript> ")
if   err_str <> " "   then
response.write( "alert( ' "&err_str& " '); ")
end   if
if   trim(str1)= " "   then
response.write( "if(history.length==0){opener= 'kingneed ';window.close()}else{history.back();} </script> ")
else
response.write( "location= ' "&str1& " '; </script> ")
end   if
response.end
end   function
提示我出错:Compiler   Error   Message:   BC30289:   Statement   cannot   appear   within   a   method   body.   End   of   method   assumed
不知道这句是什么意思,请高手帮帮忙,教教我怎么用这段程序,谢谢!

------解决方案--------------------
<script runat=server>
function SayErr(err_str as string,str1 as string)
response.write( " <script language=javascript> ")
if err_str <> " " then
response.write( "alert( ' "&ctype(err_str,string)& " '); ")
end if
if trim(str1)= " " then
response.write( "if(history.length==0){opener= 'kingneed ';window.close()}else{history.back();} ")
else
response.write( "location= ' "&ctype(str1,string)& " '; ")
end if
print( " </script "& "> ")
response.end
end function
</script>
还要咱家自己想出来,头疼!