我想在button_click事件时显示用户控件。
用户控制声明是
<div id="divloginUControl" runat="server">
<td></td>
<td>
<LUC:LoginLoader ID="loginUserControl" runat="server" />
</td>
</div>
我试过
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();
}
}
但它不起作用,请给出一些建议
答案 0 :(得分:1)
哦,试试这个
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostback)
{
loginUserControl.Visible = false;
}
}
更新:您正在使用多线程,我猜它在某些其他线程中显示为false,请检查