开发者

Master and content page in asp.net?

In my web application i am using master page concept, In master page i have login panel using this user can login, after login login panel will not visible and a link button will visible as logout, it is working fine but in one of child pages (content page) i have login panel for login which is in update panel, when user login successfully in master page login panel is still visible开发者_运维知识库 , it is not suppose to visible, when i page refresh then login panel not visible and logout link button visibling. When i login in child page the login panel in master page also not visible and log out link button will visible can u help me in this case, thank you. This is code:

SqlDataAdapter  da = new SqlDataAdapter("select * from xxx where (userid=@UserName or emailid=@UserName) and password=@Password", con);
da.SelectCommand.Parameters.AddWithValue("@UserName", txtUserId.Text);
da.SelectCommand.Parameters.AddWithValue("@Password", txtPassword.Text);
DataSet ds = new DataSet();
da.Fill(ds, "Login");
int i = ds.Tables["Login"].Rows.Count;
if (i == 1)
{
    LinkButton lnklogout = (LinkButton)Master.FindControl("LinkLogout");
    lnklogout.Visible = true;
    LinkButton linkmypro = (LinkButton)Master.FindControl("lnkbtnMyProfile");
    linkmypro.Visible = true;

    LinkButton linsynup = (LinkButton)Master.FindControl("lbtnSignUp");
    linsynup.Visible = false;
    Panel pnllogon = (Panel)Master.FindControl("LogonPanel");
    pnllogon.Visible = false;
}


You are nearly there! You need to tell the updatepanel in the master page to update itself

UpdatePanel t = (UpdatePanel)Master.FindControl("UpdatePanel1");
t.Update();

I think you also need to set the UpdateMode to "Conditional" in the updatepanel

Don't forget to have similar code in the master page as so if the person logs in using the master page's login control then the child page should be updated as well.

good luck!

edit:

Sorry I forgot to mention that you definitely need to have an updatepanel in the master page around the login control as well. Otherwise this won't work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜