Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

.NET Forum


You are currently viewing our .NET Forum as a guest. Please register to participate.
Login



Reply
hide menu from dropdownmenu
Old 05-27-2008, 01:57 AM hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
Hi ..

i am newbie in asp.net programming

my problem was:

[objective] : to hide menu from the javascript dropdownmenu

[control] : 2 user, 1 as admin and another as user ...

[introduction] : use same webpage, namely mainpage.aspx with js dropdownmenu

[problem] some of the links in the dropdownmenu were for Admin ...

how to implement javascript that can differentiate the user... If-Else ?
helpp..


my boss said that, we can hide the menu from the dropdownmenu list according to the user access level, that is 'admin' and 'user'

this is the dropdownmenu JS


PHP Code:
    <td width="50"><ul id="sddm">
      <
li><a href="#" onmouseover="mopen('m1')" onmouseout="mclosetime()">Pengguna </a>
          <
div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <a href="#">Ubah Kata Laluan </a> <a href="#">Tambah Pengguna </a> <a href="#">Hapus Pengguna </a> </div>
      </
li>
      <
li><a href="#" onmouseover="mopen('m3')" onmouseout="mclosetime()">Rekod Kursus </a>
          <
div id="m3" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <a href="kursustambah.aspx">Tambah Rekod Kursus</a> <a href="pesertatambah.aspx">Tambah Rekod Peserta</a> <a href="kursuskemaskinicari.aspx">Kemaskini Rekod Kursus</a> <a href="kursushapus.aspx">Hapus Rekod Kursus</a> </div>
      </
li>
      <
li><a href="kajiselidik.aspx" onmouseover="mopen('m4')" onmouseout="mclosetime()">Kaji Selidik </a>
      </
li>
      <
li><a href="datacari.aspx" onmouseover="mopen('m4')" onmouseout="mclosetime()">Cari Data </a></li>
      <
li><a href="#" onmouseover="mopen('m5')" onmouseout="mclosetime()">Laporan</a>
          <
div id="m5" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"><a href="laporankursuscari.aspx">Laporan Rekod Kursus</a> <a href="laporankursusbln.aspx">Laporan Kursus Bulanan Tahunan</a> <a href "laporankursuscari.aspx">Laporan Senarai Peserta</a></div>
      </
li>
      <
li><a href="#" onmouseover="mopen('m6')" onmouseout="mclosetime()">Keluar</a></li>
    </
ul>      <p></p></td>
  </
tr>
</
table>

=======================
default.
css

#sddm
{
    
margin0;
    
padding0;
    
z-index300;
    
left45px;
    
top274px;
    
width920px;
}
    
#sddm li
{    margin0;
    
padding0;
    list-
stylenone;
    
floatleft;
    
fontbold 11px arial}

#sddm li a
{    displayblock;
    
margin0 1px 0 0;
    
padding4px 10px;
    
width110px;
    
background#5970B2;
    
color#FFF;
    
text-aligncenter;
    
text-decorationnone}

#sddm li a:hover
{    background#49A3FF}

#sddm div
{    positionabsolute;
    
visibilityhidden;
    
margin0;
    
width130px;
    
padding0;
    
background#EAEBD8;
    
border1px solid #5970B2}

    #sddm div a
    
{    positionrelative;
        
displayblock;
        
margin0;
        
padding5px 10px;
        
widthauto;
        
white-spacenowrap;
        
text-alignleft;
        
text-decorationnone;
        
background#EAEBD8;
        
color#2875DE;
        
font11px arial}

    
#sddm div a:hover
    
{    background#49A3FF;
        
color#FFF} 
Nazi370 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-27-2008, 03:14 AM Re: hide menu from dropdownmenu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
If-Else
Yep

Quote:
my boss said that, we can hide the menu from the dropdownmenu list according to the user access level, that is 'admin' and 'user'
Yep
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-27-2008, 05:24 AM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
how do we put the

PHP Code:
      <li><a href="#" onmouseover="mopen('m1')" onmouseout="mclosetime()">Pengguna </a>
          <
div id="m1" onmouseover="mcancelclosetime()" onmouseout="mclosetime()"> <a href="#">Ubah Kata Laluan </a> <a href="#">Tambah Pengguna </a> <a href="#">Hapus Pengguna </a> </div>
      </
li
into the

HTML Code:
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <asp:image id="Image2" style="Z-INDEX: 109; LEFT: 752px; POSITION: absolute; TOP: 56px" runat="server"     ImageUrl="file:///C:\Inetpub\wwwroot\SMPB\JPANtransparent.gif" Height="96px" Width="104px"></asp:image>
            <asp:Label id="lblBMula" style="Z-INDEX: 138; LEFT: 344px; POSITION: absolute; TOP: 464px"
                runat="server" Width="104px" Font-Size="X-Small" Font-Names="Trebuchet MS"></asp:Label>
            <asp:label id="Label14" style="Z-INDEX: 100; LEFT: 384px; POSITION: absolute; TOP: 72px" runat="server"
                Font-Size="X-Small" Font-Names="Trebuchet MS">Tingkat 1-5, Wisma Perindustrian, Jalan Istiadat, Likas,</asp:label>
            <asp:label id="Label15" style="Z-INDEX: 102; LEFT: 440px; POSITION: absolute; TOP: 104px" runat="server"
                Font-Size="X-Small" Font-Names="Trebuchet MS">88400 Kota Kinabalu, Sabah, Malaysia.</asp:label>
</body>
since it difference in <ASP:label, dropdownlist, image, etc... >

help me to figure it out...

thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 05-28-2008, 12:56 AM Javascript hide the dropdown menu in ASP.NET
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
Hello !

i am using dropdownmenu from javascript...

let says :

|Home
|-Introduction; -About
|
|Function
|-Add new user; -Update User; -Delete User
|
|Log Out
|

i want to hide the 'Function' menu from the dropdownmenu for user but visible to Admin , within the same page... Admin and normal user will use the menu...

how can i do that in ASP.NET

thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 05-28-2008, 08:13 AM Re: hide menu from dropdownmenu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
[merged second thread on same topic]

in what code?? C#, VB, J# any other .net language you happen to be using?

and it is only a

if (admin==true) then
show this bit
end if

even a novice programmer should have learned about logic constructs
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-28-2008, 11:22 PM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
sorry chrishirst

let say my code like below

Quote:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Trim(Session("UserLogin")) = "" Then
Response.Redirect("Invalid.aspx")
End If

If Not Page.IsPostBack Then
If Trim(Session("AccessLevel")) = "Admin" Then
showMenu()
Else
hideMenu()
End If
End If
End Sub
i understand that code, but in javascript... how do we call showMenu() so it can display all the menus... and also for hideMenu()...

or is there any easy method for this function... thanks
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 05:00 AM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
i've found the code for hiding in javascript

Quote:
function showmenu()
{
var row = document.getElementById("Menu1");
if (row.style.display == '') row.style.display = 'none';
else row.style.display = '';
}
but how do i get it to vb...
when..
"
If Trim(Session("AccessLevel")) = "Admin" Then
...showMenu()
Else
"
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 05-29-2008, 06:36 AM Re: hide menu from dropdownmenu
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I don't get what you are asking?

Hiding a menu using client side styles and client side javascript is NOT "hiding" the menu. It's just not displaying it.
For non-js or non-CSS user agents (search engine bots, content scrapers etc) it is STILL visible.

This HAS to be a server side action, otherwise it is an utterly pointless exercise.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-29-2008, 08:12 PM Re: hide menu from dropdownmenu
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Use a server control, then on the Page_Load event, set that control's visibility.

MyMenuItem.Visible = Session["AccessLevel"] == "Admin";
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-02-2008, 12:23 AM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
i got it christ..

JS is client side and asp.net is server side...

its not a problem if the page that is hiding since im using session

i'll try it 'Learning Newbie'

thanks..
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 06-03-2008, 09:54 PM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
finally i've used

Quote:
If Trim(Session("AccessLevel")) = "Admin" Then
...MyMenuItem.Visible = True
Else
...MyMenuItem.Visible = False
End If

the menu must have ID and runat = "server" ...
that is <asp:label id = "MyMenuItem" ....


thanks again John... im keeping discover ASP.NET
Nazi370 is offline
Reply With Quote
View Public Profile
 
Old 06-06-2008, 03:32 PM Re: hide menu from dropdownmenu
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Nazirul, you can ignore this question if you want, but here's another way of writing the same code you have working. I'm sharing this mostly because you can use 1 line to express the same thing that you're using 5 lines for now. It's exactly the same logic, so don't think that either way will be faster than the other, or really better in any way, except if you want more or less lines.

MyMenuItem.Visible = (Trim(Session("AccessLevel")) = "Admin")

When you have an If ???? Then ___ Else ___ block of code, the if clause has to translate into a boolean (true or false) condition. Since you can only set the Visible property to true or false, you can use this short cut. You don't have to, you just can if you want. Your code reads is like If True Then MyMenuItem.Visible = True, so you can get rid of the if then else end if parts.

That applies to just about all of programming. If or when you move from VB.NET to C#, the same thing is true. And in PHP, they have the same concept.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-08-2008, 11:16 PM Re: hide menu from dropdownmenu
Nazi370's Avatar
Skilled Talker

Posts: 70
Name: Nazirul
Trades: 0
thanks ..

If newbie Then
..use long statement for understanding
Else
..blur/confuse
End If



MyMenuItem.Visible = (Trim(Session("AccessLevel")) = "Admin")

from my understanding, if AccessLevel = Admin , then MyMenuItem will be visible..
thanks again... i just only know *.visbile = True/False ... now i know them better...


i am very careful for this system since i have to work it just only for a month with newbie skill... i really appreciate your guide John...
Nazi370 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to hide menu from dropdownmenu
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.51750 seconds with 12 queries