asp.net更新面板仍刷新页面

问题描述 投票:0回答:2

我已经使用更新面板在asp.net Webform页面中进行了部分回发,但是不是部分装入而是重新装入孔页面,并且我使用了组合框对onSelectIndexChanged事件进行回发我的代码:

 <asp:UpdatePanel runat="server" ID="updatePanel1" >
            <ContentTemplate>
                <table  style="direction:rtl;width:416px;" runat="server" clientidmode="Static">
                <tr class="trwidth">
                <td>
                    <asp:DropDownList ID="comboCategory" runat="server" 
                        DataTextField="job_name" DataValueField="job_cat_id" DataSourceID="SqlDataSource1">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:JobsConnectionString %>" 
                        SelectCommand="SELECT * FROM [job_category]"></asp:SqlDataSource>
                 </td>
                    <td>

                              <asp:DropDownList ID="comboCountry" runat="server" AutoPostBack="True"  ClientIDMode="Static" DataSourceID="SqlDataSource3"  
                                  OnSelectedIndexChanged="comboCountry_OnSelectedIndexChanged"
                                    DataTextField="country_name" DataValueField="country_id">        
                                  </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:JobsConnectionString %>" 
                                    SelectCommand="SELECT * FROM [country]"></asp:SqlDataSource>          
                                </td>
                             </tr>
                            <tr class="trwidth">
                            <td>

                                <asp:DropDownList ID="comboCity" runat="server" DataSourceID="SqlDataSource2" ClientIDMode="Static"
                                    DataTextField="city_name" DataValueField="location_id">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                                    ConnectionString="<%$ ConnectionStrings:JobsConnectionString %>" 
                                    SelectCommand="SELECT * FROM [location]"></asp:SqlDataSource> 
                </td>     
                <td>

                    <asp:DropDownList ID="comboGender" runat="server" 
                        DataSourceID="SqlDataSource4" 
                        DataTextField="gender_name" DataValueField="gender_id" ClientIDMode="Static">

                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:JobsConnectionString %>" 
                        SelectCommand="SELECT * FROM [gender]"></asp:SqlDataSource>
                </td>

                 </tr>
                 <tr class="trwidth">
                <td colspan="2" style="text-align:center;padding-left: 130px;direction: ltr">
                    <dx:ASPxDateEdit ID="ASPxDateEdit" runat="server"  NullText="دوا بەروار">
                    </dx:ASPxDateEdit>
                    </td>
                </tr>
                <tr class="trwidth"><td></td>
                    <td class="dxtcLeftAlignCell">
                    </td>
                    <td></td><td></td></tr>
                <tr class="trwidth"><td>&nbsp;</td>
                    <td class="dxtcLeftAlignCell">
                        &nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>

                </tr>
                </table>

            </ContentTemplate>
        </asp:UpdatePanel>

后面的代码:

 protected void comboCountry_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                SqlDataSource2.SelectCommand = "SELECT * FROM [location] where [country_id]=" +
                                               comboCountry.SelectedValue;
                comboCity.DataBind();
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.Message);

}}

asp.net updatepanel partial-postback
2个回答
2
投票
同样,我认为标记没有任何问题-您是否在后面的代码中设置了updatepanel属性?

另一种尝试可能是使用显式触发器声明或注册-例如

<asp:UpdatePanel runat="server" ID="updatePanel1" > <Triggers> <asp:AsyncPostBackTrigger ControlID="comboCountry" /> </Triggers> ...

或等效代码,例如

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(comboCountry);

您也可以尝试将那些组合框的ClientIDMode更改为AutoID或Predictive。

0
投票
我已经在VS2013 asp.net 4.5框架中开发了我的Web应用程序。我使用过更新面板,该源在我的开发PC中工作正常。但在我的生产服务器上不起作用。

在生产服务器上,我的整个页面都刷新了

无法与带有IIS 8.5的Server 2012 R2数据中心一起使用,相同的发布代码也适用于Windows Server 2012 Standard和IIS 8

© www.soinside.com 2019 - 2024. All rights reserved.