下面这个,我想点击 <%=Session("num1")%>+<%=Session("num2")%> 刷新,要求值刷新这个局部,页面不刷新。请教高手如何实现:
<%
Randomize
Session("num1")=INT(10*RND)
Session("num2")=INT(10*RND)
%>
验证码: <%=Session("num1")%>+<%=Session("num2")%>= <input type="text" name="numcode" id="numcode"/>
<%
Randomize
Session("num1")=INT(10*RND)
Session("num2")=INT(10*RND)
%>
验证码: <%=Session("num1")%>+<%=Session("num2")%>= <input type="text" name="numcode" id="numcode"/>
Randomize
Session("num1")=INT(10*RND)
Session("num2")=INT(10*RND)Response.Write Session("num1") & " + " & Session("num2")写到一个单独的页面中,然后ajax去读取这个页面
得到的内容赋值给span即可
<%
Randomize
Session("num1")=INT(10*RND)
Session("num2")=INT(10*RND)
%>
验证码: <span id="code_pad" style="cursor:pointer" onclick="document.frames['hf'].location.href='test1.asp?' + escape(new Date())"><%=Session("num1")%>+<%=Session("num2")%></span>= <input type="text" name="numcode" id="numcode"/>
<iframe name="hf" style="display:none"></iframe>
test1.asp<%
Randomize
Dim code
Session("num1")=INT(10*RND)
Session("num2")=INT(10*RND)
code = Session("num1") + Session("num2")
%>
<script type="text/javascript">
window.onload =function(){
parent.document.getElementById('code_pad').innerHTML = "<%=code%>";
location.replace('about:blank');
}
</script>
你用js调用后台方法
具体操作
在bin文件中添加AjaxPro.dll文件
web.config文件中的<httpHandler>节点下添加<add verb="*" path="AjaxPro/*.ashx" type="AjaxPro.AjaxHandlerFactory,AjaxPro"/>在页面后台代码的Page_Load事件里添加AjaxPro.Utility.RegisterTypeForAjax(typeof(Transmitter_AddGroup));
下面是方法
[AjaxPro.AjaxMethod()]
public string codeChange()
{
验证码改变方法
}
在前台调用codeChange方法
<script>
function a()
{
var s=AjaxModel.codeChange()
document.getelementById("numcode").value=s;}
</script>
不懂的地方问我
http://www.stpbk.com/CheckCodeDemo.rar