我就是想在使用JS完成操作后,再PageLoad下页面,使我的后台代码能够顺利执行
ASPX页的代码如下,后台不需要任何代码,如果想看效果
在PageLoad里加个断点就可以了 你就可以看见每次PageLoad了
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
%>
<! 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 >
< script language ="javascript" type ="text/javascript" >
//Load信息(生成XML文件)
function pageLoad()
{
//给TextBox1设置一个焦点
document.getElementById('TextBox1').focus();
//利用提交请求刷新页面(无刷新的)
httpobj=new ActiveXObject("Microsoft.XMLHTTP");
tempfile="Default.aspx?ok=false";
httpobj.open("post",tempfile,false);
httpobj.send();
}
</ script >
< form id ="form1" runat ="server" >
< div >
< asp:TextBox ID ="TextBox1" runat ="server" AutoPostBack ="False"
Style ="position: relative" ></ asp:TextBox >
< input id ="Button1" style ="position: relative" type ="button" value ="button" onclick ="pageLoad();return false;" />
</ div >
</ form >
</ body >
</ html >
<! 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 >
< script language ="javascript" type ="text/javascript" >
//Load信息(生成XML文件)
function pageLoad()
{
//给TextBox1设置一个焦点
document.getElementById('TextBox1').focus();
//利用提交请求刷新页面(无刷新的)
httpobj=new ActiveXObject("Microsoft.XMLHTTP");
tempfile="Default.aspx?ok=false";
httpobj.open("post",tempfile,false);
httpobj.send();
}
</ script >
< form id ="form1" runat ="server" >
< div >
< asp:TextBox ID ="TextBox1" runat ="server" AutoPostBack ="False"
Style ="position: relative" ></ asp:TextBox >
< input id ="Button1" style ="position: relative" type ="button" value ="button" onclick ="pageLoad();return false;" />
</ div >
</ form >
</ body >
</ html >