locked
link button dose not control the visibility of placeholder RRS feed

  • Question

  • User-951589692 posted

    I need to hide the show place holder by clicking on  the link button, but it seems it does not work 

    this my code 

    <asp:LinkButton ID="link1" runat="server" Text="Forgot Password?" OnClick="link1_Click">
    </asp:LinkButton><br />
    <asp:PlaceHolder ID="typeEmail" runat="server" Visible="false">
    <asp:TextBox ID="textbox1" Visible="false" runat="server" AutoComplete="off">
    </asp:TextBox>
    </asp:PlaceHolder>

    code behind 

    protected void link1_Click(object sender, EventArgs e)
    {
    typeEmail.Visible = true;
    textbox1.Visible = true;

    }

    please help 

    T have been struggling with this 

    Thank you 

    Wednesday, August 24, 2016 1:05 PM

All replies

  • User-1404113929 posted

    hi,

    can you try with bellow code 

    replace in aspx page 

      <asp:LinkButton ID="link1" runat="server" Text="Forgot Password?" OnClick="link1_Click">
    </asp:LinkButton><br />
    <asp:PlaceHolder ID="typeEmail" runat="server" Visible="false">
    <asp:TextBox ID="textbox1" Visible="true" runat="server" AutoComplete="off">
    </asp:TextBox>
    </asp:PlaceHolder>

    in cs file

    protected void link1_Click(object sender, EventArgs e)
    {
    typeEmail.Visible = !typeEmail.Visible;

    }

    Thanks,

    Murali

    Thursday, August 25, 2016 5:45 AM
  • User-951589692 posted

    Thanks 

    I have tried but it still not working I mean the link button does not show the place holder when I click on it 

    please help if you can 

    I appreciate that 

    thanks 

    Thursday, August 25, 2016 8:32 AM
  • User-63706186 posted

    Hi

    As for now , can you confirm your requirement of scenario like when you will click the link button at the time place holder will be appear right. if yes mean , i have investigate of your code is working fine, otherwise share your scenario. so that i can able to assist

    Thursday, August 25, 2016 10:37 AM
  • User-1404113929 posted

    hi,

    let me know what exactly you want.

    thanks

    Thursday, August 25, 2016 11:42 AM
  • User283571144 posted

    Hi Joma Alrzini,

    I need to hide the show place holder by clicking on  the link button, but it seems it does not work 

    Could you please explain more about your requirement?

    Do you mean you want to show the place holder by clicking the button firstly, if clicking the button twice, then hide the place holder?

    If this is your requirement, I suggest you could use if condition in link1_Click event.

    More details, you could refer to follow codes:

    ASPX:

        <div>
        <asp:LinkButton ID="link1" runat="server" Text="Forgot Password?" OnClick="link1_Click">
    </asp:LinkButton><br />
    <asp:PlaceHolder ID="typeEmail" runat="server" Visible="false">
    <asp:TextBox ID="textbox1" Visible="false" runat="server" AutoComplete="off">
    </asp:TextBox>
    </asp:PlaceHolder>
        </div>

    Code-behind:

      protected void link1_Click(object sender, EventArgs e)
            {
                if (typeEmail.Visible == true)
                {
                    typeEmail.Visible = false;
                    textbox1.Visible = false;
                }
                else
                {
                    typeEmail.Visible = true;
                    textbox1.Visible = true;
                }
            }

    Best Regards,

    Brando

    Thursday, August 25, 2016 11:54 AM
  • User-951589692 posted

    Thanks

    I mean the link button is not working at all the code above has been used but when I click on the link it is not working, whereas when I replaced link botton bu normal button it is working fine, basically i need to use link button to show and hide place holder. I hope you got me 

    thanks 

    Thursday, August 25, 2016 9:11 PM
  • User-951589692 posted

    thanks 

    the link but is not working for hiding and showing place holder 

    As I mentioned in the comment below I hope you got me 

    please help 

    Thursday, August 25, 2016 9:13 PM
  • User283571144 posted

    Hi Joma Alrzini,

    I mean the link button is not working at all the code above has been used but when I click on the link it is not working, whereas when I replaced link botton bu normal button it is working fine, basically i need to use link button to show and hide place holder. I hope you got me 

    According to your description, I had tested my codes again, it works well.

    I guess there are some other reasons causes you can’t fire the event.

    I suggest you could use VS debugger and set a break point in link1_Click event, to make sure it could be executed.

    More details about how to use VS debugge breakpoints, you could refer to follow link:

    https://msdn.microsoft.com/en-us/library/5557y8b4.aspx

    Best Regards,

    Brando

    Friday, August 26, 2016 9:48 AM