ie8 postback提琴手

时间:2012-11-13 15:13:29

标签: asp.net forms internet-explorer-8 postback fiddler

我网站上的搜索表单在IE上表现不对(我试过IE8和IE7) 当我单击一个linkBut​​ton或checkBoxes时,它会启动一个回发并重置所有字段。以前找到的所有结果也会重置,页面变为空,就像第一次加载一样。

这不会发生在FF和Chrome上。

如果我运行Fiddler来查看正在发生的事情,那么该页面运行良好,并且回发将返回所有数据。我猜Fiddler纠正了它,所以我看不出IE发送到服务器的查询有什么问题。

现在,让我们看看代码。 首先,HTML页面调用.Net内容:

<iframe width="605" scrolling="AUTO" height="6000" frameborder="NO" marginwidth="0" marginheight="0" src="http://[MYSERVERNAME]/xml/dialog/rechercher.aspx?L=FR" id="iframe_"></iframe>

然后,ASPX页面文件“rechercher.aspx”:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="~/xml/Dialog/rechercher.aspx.cs" Inherits="xml_Dialog_rechercher" %>

<!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>Recherche</title>
    <link rel="stylesheet" href="css/screen.css" />
    <script type="text/javascript" src="js/dialog.js"></script>
    <!-- other js calls -->
</head>
<body style="background-image:url('/lib_central/images/ACTIV/common/bgd_main.gif');background-repeat:repeat-y;">

    <form runat="server">

        <!--
            some presentation code
            ...
        -->

        <!-- sample of one of the search fields -->
        <label for="motsClefs" class="bold"><% Response.Write(get_label("motcle")); %></label><br />
        <asp:TextBox ID="rech_kw" runat="server" value="" ForeColor="#999999" Width="250"></asp:TextBox>

        <!-- The validation field -->
        <asp:LinkButton ID="rech_valide" OnClick="lancer_recherche" runat="server" CssClass="boutons rechercher inlineBlk" >
        <span class="rechercher"><span class="alt_text">rechercher</span></span></asp:LinkButton>
        <br class="clear" />

        <%-- Results displaying --%>
        <div ID="resultats" class="contentDia alignementBlk" runat="server"></div>


        <!--
            some footer code
            ...
        -->

        <!-- Tell the parent page to stretch according to the number of results -->
        <script type="text/javascript">
            $('#iframe_666', window.parent.document).height(100+$(".contentDialogue").height());
        </script>
    </form>
</body>
</html>

最后是.Net代码:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using UsersData;

public partial class xml_Dialog_rechercher : System.Web.UI.Page
{
    string keyword = ""; // Champ de saisie texte
    List<DLG_Questions> list_q;
    public string lang;


    // Au chargement de la page
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    // If the form validation button is clicked
    protected void lancer_recherche(object sender, EventArgs e)
    {
        // If user typed something in search field
        if (get_filters())
        {
            // Query the data layer to retrieve what is searched
            this.list_q = DialogManager.recherche(this.keyword);

            // Display resultst
            if (this.list_q.Count == 0)
            {
                resultats.InnerHtml = "no results";
            }
            else
            {
                resultats.InnerHtml = display_question_list();
            }
        }
    }



    // "Read" input field controls.
    // If all empty => return FALSE
    // if some contains data => Save that data and return TRUE
    protected bool get_filters()
    {
        // ...

        return ret;
    }


    // Return a HTML of the list of themes searched
    public string display_question_list(){
        // ...
    }


    // Internationnalisation allow me to display labels in different languages
    protected string get_label(String cle)
    {
        // ...
    }
}

0 个答案:

没有答案