当前位置:编程学习 > C#/ASP.NET >>

ispostback不同的环境,值也不同,求解

有2个aspx页面 A和B
用js提交form 从A页面 提交到 B页面 

在 B页面 page_load里 判断 IsPostBack 属性 

在 window server 2003 环境里 IsPostBack  为 false

在 win8 环境里 IsPostBack  为 true


开发工具:vs2008 + DevServer


有谁知道原因? --------------------编程问答--------------------
引用 楼主 u013215218 的回复:
有2个aspx页面 A和B
用js提交form 从A页面 提交到 B页面 

在 B页面 page_load里 判断 IsPostBack 属性 

在 window server 2003 环境里 IsPostBack  为 false

在 win8 环境里 IsPostBack  为 true


开发工具:vs2008 + DevServer


有谁知道原因?


结贴太低了!!! --------------------编程问答-------------------- 刚开的账号,有碰见过的说一下 --------------------编程问答-------------------- 我不知道你要判断属性是做什么的,我觉得像下面这么写就不会有啥问题

 if (!IsPostBack)
        {
           // bind();
        } --------------------编程问答-------------------- 没有人碰到过吗?
A页面里 有 服务器text控件,输入值,用js提交form 到 B页面 B页面load事件里 判断 IsPostBack 本来 IsPostBack 应该为 false ,结果 在 win8 下面 却是 true

有喜欢研究的同学 可以试验一下  --------------------编程问答-------------------- form 设 method = post 就值都一样了 --------------------编程问答--------------------
引用 5 楼 jhl52771 的回复:
form 设 method = post 就值都一样了


试了 没有用的 --------------------编程问答-------------------- 我把试验的代码贴一下:
B.aspx 页面
-------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="B.aspx.cs" Inherits="PromotionManage.Promotion.B"  %>

<!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>
    <script type="text/javascript">
    function f()
    {
        form1.action = "B2.aspx";
        form1.method = "post";
        form1.submit();
    }
    </script>
</head>
<body>
    <form id="form1"  runat="server" method="post">
    <div>
    
       
     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    
       
    <input type="button" value="提交" onclick="f();" /></div>
    </form>
</body>
</html>

------------------------------------
B2.aspx 后台代码

protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!this.IsPostBack)
            {
                this.Response.Write("第一次加载");
            }
            else
            {
                this.Response.Write("回发");
            }
        }
-------------------------
大家有用win8的 可以试验一下  
在 win8系统里 用 2.0 netframenwork 测试结果 :回发
在 win8系统里 用 4.0 netframenwork 测试结果 :第一次加载 
在win server2003 用 2.0 netframenwork 测试结果 :第一次加载 

不知何解?

补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,