2

我想从下拉列表的选定索引更改中获取一些值并将它们绑定到 textox 或其他控件,但问题是选定索引更改后弹出窗口消失。需要解决方案。代码是

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajaxToolkit:ToolkitScriptManager>
    <div>
        <div>
        <div>
               <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
            <asp:ModalPopupExtender ID="Button1_ModalPopupExtender" runat="server" 
                Drag="True" DropShadow="True" DynamicServicePath="" Enabled="True" 
                OkControlID="btncancel" PopupControlID="Panel1" TargetControlID="Button1">
            </asp:ModalPopupExtender>

        </div>
        </div>
    </div>
      <asp:Panel ID="Panel1" runat="server">
        first name<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
        <br />
        country <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:ListItem>select</asp:ListItem>
            <asp:ListItem>india</asp:ListItem>
            <asp:ListItem>pakistan</asp:ListItem>
            <asp:ListItem>usa</asp:ListItem>
            <asp:ListItem>england</asp:ListItem>
        </asp:DropDownList>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="DropDownList1" ErrorMessage="*" InitialValue="select"></asp:RequiredFieldValidator>
        <br />
        selected country<asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Submit" />
        <input id="btncancel" type="button" value="Cancel" />
    </asp:Panel> 

后面的代码是

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        TextBox9.Text = DropDownList1.SelectedValue;
    }
4

1 回答 1

6

我相信你只需要重新发出 show 方法:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    TextBox9.Text = DropDownList1.SelectedValue;
    Button1_ModalPopupExtender.Show();
}
于 2012-04-23T20:26:02.290 回答