Dropdown menu with session
Page 1 of 111 Replies - 2069 Views - Last Post: 14 April 2011 - 02:21 AM
#1
Dropdown menu with session
Posted 08 March 2011 - 03:46 AM
I am creating a website for my project
Now i want to create a verticle menu with dropdown
the dropdwon item is User CP
now the problem is that i want to show only that perticular items/function to user that is currently loggedin into the system
eg :- If Admin has login so in UserCP dropdown all functions is shows and when user login i don't want to show all the menu items
so is it possible?
if yes so please tell me how?
Thank you
Replies To: Dropdown menu with session
#2
Re: Dropdown menu with session
Posted 08 March 2011 - 05:55 AM
This post has been edited by Nakor: 08 March 2011 - 06:04 AM
#3
Re: Dropdown menu with session
Posted 24 March 2011 - 11:56 PM
Nakor, on 08 March 2011 - 05:55 AM, said:
First i am sorry for late reply and second thanks for giving me such idea but the problem is that currently i haven't coded that menu i had created 3 Master Page of my 3 types of user Admin, Staff, Student and created Vertical menu in Master Page directly but i want Only One Master Page With Horizontal Menu and User CP Drop Down which is originally the vertical menu that are currently in Master Pages. If you want to see code so i can mail you my whole project so you can understand
#4
Re: Dropdown menu with session
Posted 25 March 2011 - 03:51 AM
#5
Re: Dropdown menu with session
Posted 25 March 2011 - 03:34 PM
there is however a dropdown.Items.Remove("your item name to remove");
The following code will illustrate how to use it
if (User == Valid)
{
//firts clear the Dropdown
ddl.Items.Clear();
//Populate new items
ddl.Items.Add("Logout");
ddl.Items.Add("Profile");
}
else
{
//If he is not admin the use item.remove();
ddl.Items.Remove("The item { name } to remove from dropdownlist");
}
You will have to modify code to fit your needs but i hope its what you want
Greetings
Marinus
This post has been edited by marinus: 25 March 2011 - 03:35 PM
#6
Re: Dropdown menu with session
Posted 14 April 2011 - 01:07 AM
HTML Code
<div class="menu"> <ul> <li><a href="#" >Home</a></li> <li><a href="/news.aspx">What's New?</a></li> <li><a href="/faq.aspx">F.A.Q.</a></li> <li><a href="/about.aspx">About Us</a></li> <li><a href="/contact.aspx">Contact Us</a></li> <li><a href="#">User CP</a> <ul> <li><a href="#">View Profile</a></li> <li><a href="#">Change Password</a></li> <li><a href="#">Create User</a></li> <li><a href="#">View User</a></li> <li><a href="#">Send SMS</a></li> <li><a href="#">Send email</a></li> <li><a href="#">Post News</a></li> <li><a href="#">Logout</a></li> </ul> </li> </ul> </div>
CSS
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
font: 67.5% "Lucida Sans Unicode", "Bitstream Vera Sans", "Trebuchet Unicode MS", "Lucida Grande", Verdana, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
}
.menu ul{
background:#333333;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li{
float:left;
padding:0px;
}
.menu li a{
background:#333333 url("images/seperator.gif") bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
.menu li a:hover, .menu ul li:hover a{
background: #309bcf url("images/hover.png") bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
.menu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:1em;
/*left:0;*/
}
.menu li:hover ul{
display:block;
}
.menu li li {
background:url('images/sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
.menu li ul a:hover, .menu li ul li:hover a{
background:#309bcf url('images/hover_sub.png') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
.menu p{
clear:left;
}
I want to control User CP i don't want to show all the items from it visible to student like Send SMS and Send email..etc
Images are attached please see the attachment and please give me proper solution
Thanks & Regards
Jaimin
Attached image(s)
This post has been edited by jammu143: 14 April 2011 - 01:11 AM
#7
Re: Dropdown menu with session
Posted 14 April 2011 - 01:12 AM
<li runat="server" id="mnuLogout" ><a href="#">Logout</a></li>
Where runat server tag makes the control\menu available for server side processing.
C# code.
EDIT
if(!LoggedIn){
mnuLogout.Visible = False;
//This will hide logout menu when user not logged in
mnuLogout.Style
//To override style attribute go for
mnuLogout.Style.Add("background-image", "image1.jpg");
//Changes the image on serverside
}
Once the control is accesable in server side , then use the Control.Style Property to set it
To chage the image use
Control.Style.Add("background-image", "image1.jpg");
Super Cool huh!
This post has been edited by marinus: 14 April 2011 - 01:30 AM
#8
Re: Dropdown menu with session
Posted 14 April 2011 - 01:30 AM
#9
Re: Dropdown menu with session
Posted 14 April 2011 - 01:55 AM
i had tried it i had created one another master page and
and without checking any condition i tried to hide menu item Logout by this code
<li runat="server" id="mnuLogout" ><a href="#">Logout</a></li>
Ans in CS file in Page lode event
protected void Page_Load(object sender, EventArgs e)
{
mnuLogout.Visible = False;
}
and add this master page to one test page and when i view it in browser it is showing following error
Compiler Error Message: CS0103: The name 'False' does not exist in the current context
#10
Re: Dropdown menu with session
Posted 14 April 2011 - 02:06 AM
False should be false , small caps
This post has been edited by marinus: 14 April 2011 - 02:08 AM
#11
Re: Dropdown menu with session
Posted 14 April 2011 - 02:18 AM
marinus, on 14 April 2011 - 02:06 AM, said:
False should be false , small caps
Wolaaaaaaaaa it's 100% Working now thank you so much you don't know how big problem you had solved because of this problem i had created 3 Different master page though problem is that in some pages i have to add 2 master page which is not possible so i am very confused but now i got the solution....yapeeeeeeeee
Thanks again
#12
Re: Dropdown menu with session
Posted 14 April 2011 - 02:21 AM
You can use this method for any html tag . Its a tenique that will help you in web developement and took me a year to discovery it ,
Now you know what runat="server" does , it's a very powerful tag.
This post has been edited by marinus: 14 April 2011 - 02:25 AM
|
|

New Topic/Question
Reply




MultiQuote




|