0

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.

Bhasker Vengala
  • 103
  • 5
  • 19
  • 1
    Please provide your real code. `loginuc.visbile=true;` would not even compile. It's also not clear what you mean with _submit button_ and where you try to hide the control. Your title is: _"Hide from Page_Load"_ but your real question seems to be _"Hide from button-click event"_, is this correct? – Tim Schmelter Nov 27 '13 at 09:05
  • nope, I just hide the control from page_load and show the control from button_click event. I have edited my code, pls check it – Bhasker Vengala Nov 27 '13 at 09:19
  • Does the Button1_Click get called at all? Have you tried setting a breakpoint? Does Button1_Click get called after Page_Load as it should? Isn't there something else in the loginUserControl logic that could be hiding it? – Luaan Nov 27 '13 at 09:46

2 Answers2

1

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.

Luaan
  • 62,244
  • 7
  • 97
  • 116
0

@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.

Piyush
  • 120
  • 1
  • 9