Click here to Skip to main content
15,914,162 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,


I want to using modal popup according to textbox value. i.e when i write a string like "test" in textbox, modal popup show. I try to this with textbox change event, but it didn't.

here is my code:

aspx file:
XML
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="Btnshow" runat="server" Text="Show" OnClick="Btnshow_Click" />
        <asp:Button ID="BtnTarget" runat="server" Text="Target" Style="display: none" />
        <asp:TextBox ID="TextBox1" runat="server">
        </asp:TextBox>
        <input type="button" value="Get" onclick="abc()" />
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="BtnTarget"
            PopupControlID="Panel1">
        </asp:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" BackColor="Black" Width="300px" Height="300px">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Button ID="BtnHide" runat="server" Text="Hide Button" OnClick="BtnHide_Click" />
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="BtnHide" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Btnshow" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>



cs file:

C#
protected void TxtProject_TextChanged(object sender, EventArgs e)
        {
            KurumAdi = TxtProject.Text;
            if (TxtProject.Text == "test")
            {
                Btnshow_Click(null, null);
            }
        }

        protected void Btnshow_Click(object sender, EventArgs e)
        {
            ModalPopupExtender1.Show();
        }
        protected void BtnHide_Click(object sender, EventArgs e)
        {
            ModalPopupExtender1.Hide();
        }
Posted
Updated 3-Apr-14 23:54pm
v2

1 solution

Hi,
Put AutoPostBack="true" in your textbox
<asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true">

Also add textbox id in AsyncPostBackTrigger ,
XML
<Triggers>
        <asp:AsyncPostBackTrigger ControlID="TextBox1"/>
    </Triggers>


this would work.
 
Share this answer
 
v2
Comments
Member 10724146 4-Apr-14 6:41am    
Thank you so much, it worked :)
jacobjohn196 4-Apr-14 7:09am    
you are welcome. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900