show user control when button_click event

63 views Asked by At

I want to display user control when button_click event.

The user contol declartion is

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

I have tried with

protected void Page_Load(object sender, EventArgs e)
    {

        loginUserControl.Visible = false;
    }

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

        System.Threading.Thread.Sleep(5000);
        ScriptManager1.RegisterPostBackControl(Button1);
        string result = asset.UserLogin(txtloginid.Text, txtpassword.Text);
        if (Convert.ToInt32(result) == 1)
        {
            Session["uname"] = txtloginid.Text;
            Server.Transfer("CreatedInventory.aspx");
        }
        else
        {
            pwdinfo.Text = "Please enter correct password";
            txtpassword.Focus();
        }
    }

but it is not working, please give some suggetions

1

There are 1 answers

4
tariq On BEST ANSWER

oh got it try this

protected void Page_Load(object sender, EventArgs e)
{
    if(!Page.IsPostback)
    {
        loginUserControl.Visible = false;
    }
}

Update : you are using multithreading right, i guess that its getting visible false in some other thread, check that