国家和州下拉列表的更新面板无法正常工作意味着整个页面更新

国家和州下拉列表的更新面板无法正常工作意味着整个页面更新

本文介绍了国家和州下拉列表的更新面板无法正常工作意味着整个页面更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两个下拉列表中使用更新面板。我想在从国家/地区下拉菜单中选择值时相应的状态将出现在状态下拉列表中,它完成但是当我从国家/地区下拉菜单中选择值时整个页面令人耳目一新,这是我不想要的。我该怎么办?





这里是我的aspx页面代码:





I am using update panel on two dropdown. I want when selecting value from country dropdown corresponding state will appear in state dropdown, it is done but as I select value from country dropdown whole page is refreshing, which i dont want. What can i do for this?


here is my aspx page code:





<asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <div>
    <table>
    <tr>
    <td>First Name
    </td>
    <td>
        <asp:TextBox ID="txtfname" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"

            ErrorMessage="Enter First Name" ControlToValidate="txtfname"></asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr>
    <td class="style1">Last Name
    </td>
    <td class="style1">
        <asp:TextBox ID="txtlname" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"

            ErrorMessage="Enter Last  Name" ControlToValidate="txtlname"></asp:RequiredFieldValidator>
    </td>
    </tr>


    <tr>

    <td>User Name
    </td>
    <td>


        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>


                <asp:TextBox ID="txtuname" runat="server" AutoPostBack="True"

            ontextchanged="TextBox1_TextChanged"></asp:TextBox>
        <asp:Label ID="lbluname" runat="server" Visible="false" ></asp:Label>

        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"

            ErrorMessage="Enter User Name" ControlToValidate="txtuname"></asp:RequiredFieldValidator>
            </ContentTemplate>
            <Triggers>
            <asp:PostBackTrigger ControlID="txtuname" />
            <%--<asp:AsyncPostBackTrigger ControlID="txtuname" EventName="TextChanged" />--%>
            </Triggers>
        </asp:UpdatePanel>



        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
        <img src="images/ajax.gif" width="50px" height="50px" />
        </ProgressTemplate>
        </asp:UpdateProgress>

    </td>


    </tr>



    <tr>
    <td>Gender
    </td>
    <td>

        <asp:RadioButtonList ID="rbgender" runat="server"

            RepeatDirection="Horizontal">
            <asp:ListItem>Male</asp:ListItem>
            <asp:ListItem>Female</asp:ListItem>
        </asp:RadioButtonList>

        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"

            ControlToValidate="rbgender" ErrorMessage="Select Gender"></asp:RequiredFieldValidator>

    </td>
    </tr>
    <tr>
    <td>Email
    </td>
    <td>

        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
        <ContentTemplate>



        <asp:TextBox ID="txtemail" runat="server" ontextchanged="txtemail_TextChanged"

            AutoPostBack="True"></asp:TextBox>
            <asp:Label ID="lblemail" runat="server" Visible="false" ></asp:Label>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"

            ControlToValidate="txtemail" ErrorMessage="Enter Email"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"

            ErrorMessage="Enter correct format" ControlToValidate="txtemail"

            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <asp:CompareValidator ID="CompareValidator1" runat="server"

            ErrorMessage="Enter Same Email address" ControlToCompare="txtemail"

            ControlToValidate="txtConfirmemail"></asp:CompareValidator>
            </ContentTemplate>
            <Triggers>
            <asp:PostBackTrigger ControlID="txtemail" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
        <ProgressTemplate>
        <img src="images/ajax.gif" width="50px" height="50px" />
        </ProgressTemplate>
        </asp:UpdateProgress>
    </td>
    </tr>
    <tr>
    <td>Confirm Email
    </td>
    <td>
        <asp:TextBox ID="txtConfirmemail" runat="server"></asp:TextBox>
    </td>
    </tr>

    <tr>
    <td>Password
    </td>
    <td>
        <asp:TextBox ID="txtpassword" runat="server" TextMode="Password"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"

            ErrorMessage="Enter Password" ControlToValidate="txtpassword"></asp:RequiredFieldValidator>
        <asp:CompareValidator ID="CompareValidator2" runat="server"

            ErrorMessage="Enter same password" ControlToCompare="txtpassword"

            ControlToValidate="txtconfirmpassword"></asp:CompareValidator>
    </td>
    </tr>
    <tr>
    <td>Confirm Password
    </td>
    <td>
        <asp:TextBox ID="txtconfirmpassword" runat="server" TextMode="Password"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>DOB
    </td>
    <td>
        <asp:TextBox ID="txtdob" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"

            ErrorMessage="Enter DOB" ControlToValidate="txtdob"></asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr>
    <td>Address
    </td>
    <td>
        <asp:TextBox ID="txtaddress" runat="server" TextMode="MultiLine"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"

            ErrorMessage="Enter Address" ControlToValidate="txtaddress"></asp:RequiredFieldValidator>
    </td>
    </tr>


        <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <tr>
    <td>
        Country
    </td>
    <td>
        <asp:DropDownList ID="ddlcountry" runat="server" AutoPostBack="True"

            onselectedindexchanged="ddlcountry_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"

            ErrorMessage="Choose Country" ControlToValidate="ddlcountry"></asp:RequiredFieldValidator>
    </td>
    </tr>




    <tr>
    <td>State
    </td>
    <td>
        <asp:DropDownList ID="ddlstate" runat="server" >

        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server"

            ErrorMessage="Choose State" ControlToValidate="ddlstate"></asp:RequiredFieldValidator>
    </td>
    </tr>

   </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="ddlcountry"  />
   <%--<asp:PostBackTrigger ControlID="ddlcountry" />--%>
    </Triggers>
    </asp:UpdatePanel>





<tr>
<td>
City
</td>
<td>
    <asp:TextBox ID="txtCity" runat="server"></asp:TextBox>
</td>
</tr>




    <tr>
    <td>PinCode
    </td>
    <td>
        <asp:TextBox ID="txtpincode" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server"

            ErrorMessage="Enter Pin Code" ControlToValidate="txtpincode"></asp:RequiredFieldValidator>
    </td>
    </tr>
    <tr>
    <td>
    </td>
    <td>
        <asp:Button ID="btnsubmit" runat="server" Text="Submit"

            onclick="btnsubmit_Click" />
    </td>
    </tr>
    </table>
    </div>

推荐答案


<asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"

                    onselectedindexchanged="DropDownList1_SelectedIndexChanged">
                    <asp:ListItem Value="0">India</asp:ListItem>
                    <asp:ListItem Value="1">US</asp:ListItem>
                    <asp:ListItem Value="3">China</asp:ListItem>
                </asp:DropDownList>
                <br />
<br />
                <asp:DropDownList ID="DropDownList2" runat="server">
                </asp:DropDownList>
            </ContentTemplate>
        </asp:UpdatePanel>





I hope it will work.



I hope it will work.


这篇关于国家和州下拉列表的更新面板无法正常工作意味着整个页面更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 03:15