简体   繁体   中英

Hide web user control from page load

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.

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.

@bhasker ..一种方法是,您可以在用户控制类中定义一个属性,以隐藏或显示UC控件,并在使用UC的屏幕上相应地隐藏或显示用户控件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM