Click here to Skip to main content
15,887,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone.. can somebody give me some reference on how to create user control that cannot seen by other member in a webpage? I already google it but there are links that not exact on what i want to do..

thanks in advance
Posted
Comments
bbirajdar 11-Jun-13 6:28am    
if(username!="myuser")
{
ucUserControl1.Visible=false;
}

1 solution

You did not find anything, because people don't have to create a control to be visible or not; such feature (control visibility) already exists. However, it's simpler than that: your ASP.NET generates the whole Web page, so you can write some elements conditionally, depending on the permissions of current user.

—SA
 
Share this answer
 
Comments
Shahin Khorshidnia 11-Jun-13 7:46am    
+5
Sergey Alexandrovich Kryukov 11-Jun-13 7:53am    
Thank you, Shahin.
—SA
Member 10033107 12-Jun-13 20:42pm    
yes i know that.. okay this is what i meant to say.. I created a user roles in my page wherein the registered roles has different page that can only be access in different user... this is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim user
user = Request.QueryString("muser")

If user = "" Then
Response.Redirect("loginuser.aspx")
Else
labUser.Text = ""
End If


'Dim n As Integer = [String].Compare(Request.QueryString("username"), "")
'If n <= 0 Then
' Server.Transfer("defmain.aspx")
'Else
' labWelcome.Text = "Welcome, " & Request.QueryString("username") & "!"
'End If

Select Case Request.QueryString("userroles")
Case "1"
mnMain.Items(0).NavigateUrl = "~/CyberyaLogo.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")

mnMain.Items(1).ChildItems(1).NavigateUrl = "~/Sales.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")
mnMain.Items(1).ChildItems(2).NavigateUrl = "~/RFC.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(3).NavigateUrl = "~/Marketing.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(4).NavigateUrl = "~/PCExpress.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(5).NavigateUrl = "~/Client.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
ifMain.Attributes("src") = "CyberyaLogo.aspx?userrole=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")
Exit Select
Case "2"
mnMain.Items(0).NavigateUrl = "~/CyberyaLogo.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")

mnMain.Items(1).ChildItems(1).NavigateUrl = "~/Sales.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")
mnMain.Items(1).ChildItems(2).NavigateUrl = "~/RFC.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(3).NavigateUrl = "~/Marketing.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(4).NavigateUrl = "~/PCExpress.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
mnMain.Items(1).ChildItems(5).NavigateUrl = "~/Client.aspx?userroles=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username") & "&mode=0"
ifMain.Attributes("src") = "CyberyaLogo.aspx?userrole=" & Request.QueryString("userroles") & "&username=" & Request.QueryString("username")
If Not IsPostBack Then
'mnMain.Items[1].ChildItems.RemoveAt(3);
mnMain.Items.RemoveAt(2)

End If
Exit Select
Case Else
Exit Select
End Select
End Sub
Member 10033107 12-Jun-13 20:45pm    
wherein im looking forward to create a login user that he/she only access a limited pages yet i have trouble in here that still he/she saw all pages that not to be access on that page.. i hope you understand what im meant to say thanks
Sergey Alexandrovich Kryukov 12-Jun-13 20:47pm    
I think I understand that, I still don't see what's the problem to implement that.
—SA

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