function myfun(element)
{
element.value=<%=text>;
}
<%
text="hello"
%>我想在myfun里给elelment.value赋值,用下面的text变量,这样写不行,想请高手帮帮忙~在此谢过了先~~
{
element.value=<%=text>;
}
<%
text="hello"
%>我想在myfun里给elelment.value赋值,用下面的text变量,这样写不行,想请高手帮帮忙~在此谢过了先~~
text="hello"
%>function myfun(element)
{
alert(<%=text>);
element.value= <%=text> ;
}
dim s
s="hello"
%>
<script>
alert("<%=s%>");
</script>
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
</head>
<body>
<form id="form1">
<div> <%
dim testinasp;
testinasp="hello world!";
%> <script type="text/javascript">
alert("<%=testinasp %>");
</script>
</div>
</form>
</body>
</html>弹出的对话框是<%=testinasp%>
不是hello world!
<script type="text/javascript">
alert("<%=testinasp %>");
</script>
能行么?
而且asp.net的内联代码不是用<%%>标记的,而是用<script runat=server></script>标记的。
而且你的代码头部定义使用c#,但是代码中却是用的是vb的语法。
这样修改试试:
<%@ Page Language="C#"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title> 无标题页 </title>
</head>
<body>
<form id="form1">
<div> <script runat="server">
String testinasp="hello world!";
>/script> <script type="text/javascript">
alert(" <%=testinasp %> ");
</script>
</div>
</form>
</body>
</html>
扩展名需要修改为aspx。
改过来当然行,但是不让改啊~
我现在就是在htm里想连接数据库,现在想查看变量的值,不知道怎么查看,就想用这种方式访问一下,看是否正确了~
我刚接触这东西,好多都不懂呢~呵呵
如果想用Htm来实现的话,只能使用Ajax技术。
然后再调用
function myfun(element)
{
element.value=document.all.test.value ;
}