Hide web user control from page load

2k views Asked by At

I have created one web user control and I placed that in login page. When I click on submit button the user control has to display and it will redirect to home page.

Coming to my code, I have placed that user control in

<div id="divloginUControl">
    <td></td>
       <td>
           <LUC:LoginLoader ID="loginUserControl" runat="server" />
       </td>
 </div>

When the login page is loaded the user control is highlighting. For hiding user control I wrote

protected void Page_Load(object sender, EventArgs e)
    {
        //divloginUControl.Visible = false;
        loginUserControl.Visible = false;
    }

and for submit button

 protected void Button1_Click(object sender, EventArgs e)
    {
        loginUserControl.Visible = true;
    }

but it is not working for submit button.

Please give suggestions.

2

There are 2 answers

0
Luaan On

In what event are you setting the Visible property? If you're doing it in inline code, that is processed after the event handlers, so you'll just set Visible back to false just before final rendering.

0
Piyush On

@bhasker.. One approach can be that you define a property in your user conrtrol class that hide or shows the controls of your UC and on your screen where the UC is used, you can hide or show your user control accordingly.