Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I have a master page from which i derive all the pages. On the master page i have a label called userLoginName (by default the text is blank.)

From the login page , on the click event of the login button i have this code:

VB
Dim _logName = Trim(LoginName.Text)
Dim _pwd = Trim(Password.Text)

If Me.ValidateUser(_logName, _pwd) = True Then

    'display users etails

    Dim mpLabel As Label
    mpLabel = CType(Master.FindControl("userLoginName "), Label)

    'change the userLoginName text to: your login is successfull + user Name
     mpLabel.Text = "your login is successfull" & _logName

    'Redirect user to the appropriate page
    If ViewState("_UserPrivilege") = "Administrator" Then
        Response.Redirect("~/Adminstrator/index.aspx")
    ElseIf ViewState("_UserPrivilege") = "Terminal User" Then
        Response.Redirect("~/TerminalUsers/index.aspx")
    End If

Else
    StatusLabel.Text = "Please your login Name or Password is incorrect."
    Exit Sub
End If


After Redirecting the page to the appropriate page, then i dont see the message + user login name.

plz any help
Posted
Comments
Herman<T>.Instance 9-Aug-11 16:42pm    
and what code is used in the masterpage? is label userLoginName set to "" or Nothing?

1 solution

There's all sorts of issues with this code. However, at the core, the way I always do this, is to create a base page class for all my pages. In that base class, I expose a property which is the Master property of the page, cast to the type of the MasterPage class I am using. Having done that, I can easily interact with my master page in my content pages. However, I would NEVER expose the textbox directly, I'd expose a property to get and set it's text.
 
Share this answer
 
Comments
Djamanet 10-Aug-11 5:04am    
i see, using the set and get method from a property created on the master page.
- you mean all the pages must access this property on their page load event?

but can you give a sample example of what your are talking about? both from the proprety of the master page and one content page.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900