asp:IE中的按钮执行问题

时间:2011-04-15 10:24:48

标签: c# asp.net

<asp:Button ID="btnFind" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, SearchButtonText %>" CssClass="submit" 
                OnClick="btnFind_Click" ValidationGroup="TopSearch" />

但是btnFind_Click从未在IE中执行过。它适用于FF和Opera。问题仅出现在IE中。也许有人知道当我点击它时btnFind_Click无法执行的问题在哪里?

编辑:

我发现asp:linkbutton有效,问题只出在asp:button

编辑2:

代码:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="SearchPage.master.cs"
    Inherits="ViaMura.Web.MasterPage.SearchPage" %>
<!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">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <asp:ContentPlaceHolder ID="cpDescription" runat="server">
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder ID="cpKeywords" runat="server">
    </asp:ContentPlaceHolder>
    <meta name="copyright" content="&copy; 2010 viamura.si" />
    <meta name="robots" content="index,follow" />
    <meta name="rating" content="General" />
    <link href="~/images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <link href="~/css/results.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="~/css/map.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="~/css/weather.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="~/css/sexyalertBox.css" rel="stylesheet" type="text/css" media="screen" />
    <script type="text/javascript" src="/js/jQuery/jquery.1.3.1.min.js"></script>    
    <script type="text/javascript" src="/js/jQuery/jquery.easing.1.3.js"></script>
    <script type="text/javascript" src="/js/jQuery/jquery.sexyalertbox.1.2.js"></script>
    <script type="text/javascript" src="/js/display.js"></script>
    <script type="text/javascript" src="/js/animatedCollapse.js"></script>
    <script type="text/javascript" src="/js/jQuery/jquery.ajaxConten.2.1.js"></script>
    <asp:Literal ID="litIE6" runat="server" Text=""></asp:Literal>
    <asp:ContentPlaceHolder ID="cpHead" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body onload="load();"> 
    <form id="form1" runat="server" DefaultButton="btnFind">
    <asp:ScriptManager ID="smSearchPage" runat="server" EnablePageMethods="true">        
    </asp:ScriptManager>
    <asp:UpdatePanel ID="upnDefault" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:Literal ID="litHiddenFields" runat="server"></asp:Literal>
    <div id="top_menu">
        <asp:HyperLink ID="hlHome" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, HomeTopButtonText %>" NavigateUrl="~/Default.aspx"></asp:HyperLink>
        · <asp:HyperLink ID="hlAddSite" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, AddSiteTopButtonText %>" NavigateUrl="~/EnterSite.aspx"></asp:HyperLink>
        · <asp:HyperLink ID="hlAbout" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, AboutTopButtonText %>" NavigateUrl="~/About.aspx"></asp:HyperLink>
        · <asp:HyperLink ID="hlHelp" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, HelpTopButtonText %>" NavigateUrl="~/Help.aspx"></asp:HyperLink>
        · <asp:HyperLink ID="hlMarketing" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, MarketingTopButtonText %>" NavigateUrl="~/Marketing.aspx"></asp:HyperLink>
        · <asp:HyperLink ID="hlInfo" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, InfoTopButtonText %>" NavigateUrl="~/Info.aspx"></asp:HyperLink>       
    </div>
    <div id="search_container">
        <a id="logoLink" runat="server"><img src="/images/results_logo.png" class="image" alt="viamura" /></a>
        <div id="search">
            <div id="tabs">
            <ul>              
                <li>
                    <div ID="btnWebL" runat="server" class="left_selected"></div>
                    <asp:LinkButton ID="btnWeb" runat="server" CssClass="center_selected" OnClick="btnWeb_Click"
                        Text="<%$ Resources:ViaMura.Web.Default, WebSearchButtonText %>"></asp:LinkButton>
                    <div ID="btnWebR" runat="server" class="right_selected"></div>
                </li>
                <li>
                    <div ID="btnMapL" runat="server" class="left"></div>
                    <asp:LinkButton ID="btnMap" runat="server" CssClass="center" OnClick="btnMap_Click"
                        Text="<%$ Resources:ViaMura.Web.Default, MapSearchButtonText %>"></asp:LinkButton>
                    <div ID="btnMapR" runat="server" class="right"></div>
                </li>
                <li>
                    <div ID="btnWeatherL" runat="server" class="left"></div>
                    <asp:LinkButton ID="btnWeather" runat="server" CssClass="center" OnClick="btnWeather_Click"
                        Text="<%$ Resources:ViaMura.Web.Default, WeatherSearchButtonText %>"></asp:LinkButton>
                    <div ID="btnWeatherR" runat="server" class="right"></div>
                </li>
                <li>
                    <div ID="btnImagesL" runat="server" class="left"></div>
                    <asp:LinkButton ID="btnImages" runat="server" CssClass="center" OnClick="btnImages_Click"
                        Text="<%$ Resources:ViaMura.Web.Default, PicturesSearchButtonText %>"></asp:LinkButton>
                    <div ID="btnImagesR" runat="server" class="right"></div>
                </li>
                <li>
                    <div ID="btnConverterL" runat="server" class="left"></div>
                    <asp:LinkButton ID="btnConverter" runat="server" CssClass="center" OnClick="btnConverter_Click"
                        Text="<%$ Resources:ViaMura.Web.Default, ConverterSearchButtonText %>"></asp:LinkButton>
                    <div ID="btnConverterR" runat="server" class="right"></div>
                </li>
            </ul>
            </div>
            <img src="/images/bg_search_med_left.png" align="left" alt="&lt;" /><asp:TextBox ID="txtFind"
                runat="server" CssClass="search" ValidationGroup="TopSearch"></asp:TextBox>
            <img src="/images/bg_search_med_right.png"
                    align="left" alt="&gt;" />                    
            <asp:LinkButton ID="btnFind" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, SearchButtonText %>" CssClass="submit"
                OnClick="btnFind_Click" ValidationGroup="TopSearch" />                  
            <div class="validation_error">
                <asp:RequiredFieldValidator ID="rfvtxtFind" runat="server" 
                    ErrorMessage="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, RequiredFieldTextOnSearchButton %>" ControlToValidate="txtFind" CssClass="validator" 
                    ValidationGroup="TopSearch" Display="Dynamic"></asp:RequiredFieldValidator>
            </div>
        </div>
        <div id="hints">
            <asp:Literal ID="litSuggestedForms" runat="server"></asp:Literal>
        </div>
        <hr />
    </div>
    <div id="results">
        <asp:ContentPlaceHolder ID="cplResults" runat="server">
        </asp:ContentPlaceHolder>
        <div id="results_search">
            <img src="/images/bg_search_sml_left.png" align="left" alt="&lt;" /><asp:TextBox ID="txtSmallSearch"
                runat="server" CssClass="search" ValidationGroup="BottomSearch"></asp:TextBox>
        <img src="/images/bg_search_sml_right.png" align="left" alt="&gt;" /> 
        <asp:Button ID="btnSmallFind" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, SmallSearchButtonText %>"
            CssClass="submit" onclick="btnSmallFind_Click" ValidationGroup="BottomSearch" />                 
        </div>    
        <div class="validation_error">
            <asp:RequiredFieldValidator ID="rfvtxtSmallSearch" runat="server" 
                    ErrorMessage="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, RequiredFieldTextOnSmallSearchButton %>" ControlToValidate="txtSmallSearch" 
                    ValidationGroup="BottomSearch" Display="Dynamic"></asp:RequiredFieldValidator>           
        </div>
    </div>
    <div id="sidebar">
        <asp:Repeater ID="rptItems" runat="server">
            <HeaderTemplate>
            </HeaderTemplate>
            <ItemTemplate>
                <div class="item">
                    <a href='<%#Eval("Url")%>' target="_blank" ID="imageLink" class="image" runat="server"><img src='<%#GetImage(Eval("idAdvertisementCompanies"))%>' ID="imageSrc" runat="server" height='<%# Convert.ToInt32(Eval("Height"))%>' width='<%# Convert.ToInt32(Eval("Width"))%>' alt="img" align="left" /></a>
                    <p class="name"><asp:Label ID="lblName" runat="server" Text='<%#Eval("Name")%>'></asp:Label></p>        
                    <p><asp:Label ID="lblDescription" runat="server" Text='<%#Eval("Description")%>'></asp:Label></p>        
                </div>
            </ItemTemplate>
            <FooterTemplate>
            </FooterTemplate>
        </asp:Repeater>     
        <div class="item" style="border: none; margin: 0;">
            &nbsp;
        </div>
        <div class="top_search">
            <h2><asp:Label ID="lblPaidMostPopularSearches" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, FrequentlySearchedQueriesText %>"></asp:Label></h2>
            <ul>
                <asp:Literal ID="litPaidMostPopularSearches" runat="server"></asp:Literal>
            </ul>
        </div>
        <div style="clear: both; "></div>
        <br /><br />
        <div class="top_search">
            <h2><asp:Label ID="lblPaidTopSearches" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, PaidTopSearchesText %>"></asp:Label></h2>
            <ul>
                <asp:Literal ID="litPaidTopSearch" runat="server"></asp:Literal>
            </ul>
        </div>
    </div>
    <div id="footer">
        <div>
            <% /*<asp:LinkButton ID="lbSlo" runat="server" CssClass="slo"
                Text="" onclick="lbSlo_Click"></asp:LinkButton>            
            <asp:LinkButton ID="lbDeu" runat="server" CssClass="deu"
                Text="" onclick="lbDeu_Click"></asp:LinkButton>  
            <asp:LinkButton ID="lbAus" runat="server" CssClass="aus"
                Text="" onclick="lbAus_Click"></asp:LinkButton>*/ %>
            <a href="http://www.viamura.si" class="slo"></a>
            <a href="http://www.viamura.de" class="deu"></a>
            <a href="http://www.viamura.at" class="aus"></a>
        </div>
        <asp:HyperLink ID="hlInfoButtomLink" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, InfoButtomLinkText %>" NavigateUrl="~/Info.aspx"></asp:HyperLink>
         · 
        <asp:HyperLink ID="hlAboutButtomLink" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, AboutButtomLinkText %>" NavigateUrl="~/About.aspx"></asp:HyperLink>
         · 
        <asp:HyperLink ID="hlMarketingButtomLink" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, MarketingButtomLinkText %>" NavigateUrl="~/Marketing.aspx"></asp:HyperLink>        
        <br />
        <asp:Literal ID="litFooter" runat="server" Text="<%$ Resources:ViaMura.Web.MasterPage.SearchPage, FooterText %>"></asp:Literal>         
    </div>
    </ContentTemplate>
    </asp:UpdatePanel>
    </form>
    <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-3307705-3']);
        _gaq.push(['_trackPageview']);
        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
    </script>
</body>
</html>

3 个答案:

答案 0 :(得分:3)

代码的执行与浏览器无关,除非您的代码根据某些用户变量(如用户代理)执行不同。

所以问题很可能不在服务器端。

看一下你所拥有的任何Javascript IE可能因某些原因阻止帖子。如果页面上存在脚本错误,则可能导致此错误。

答案 1 :(得分:2)

请看一下这个链接:DoPostBakcWithOptions

问题可能是WebResource.axd提供的js函数WebForm_DoPostBackWithOptions,并且由于某种原因,HTTPModule可能会干扰处理程序。

尝试删除HTTPModule并检查按钮是否执行PostBack。

答案 2 :(得分:0)

如果有人遇到类似的问题,

找到解决方案。当你有超过1个表单并且他们不知道哪个表单执行时,IE和Opera会出现问题。 STRANGE IE !!!

LINK我找到了帮助:http://forums.asp.net/t/1035522.aspx/1?Submit+buttons+not+working+in+IE