Click here to Skip to main content
13,197,548 members (49,912 online)
Rate this:
Please Sign up or sign in to vote.
Hi friends, I have small doubt in web app

I have 2 divs for 2 types of menu's i.e one menu for All Users except Admin Login and Other

Menu is for Admin Login because I have used this I want to give only some permissions to

users and all permissions to Admin.

For that I have taken 2 div's in which all is HTML Menu Code. based on Session value I am

hiding the menu. every thing is fine but one small problem that I am using javascript ajax

functions to call web service so when any alert message comes the other menu which I was

hiding for that particular session is also visible till I press the message box Ok or Cancel Button.

How can I solve this and I want two menu's also for my logic. Is there any method to solve


Please any one can help me with this problem

Thanks & Regards
Posted 11-Dec-12 17:30pm
vishal jodh 11-Dec-12 23:45pm
pls past u r java script code so i can understand better
Ganeshcse 13-Dec-12 3:59am
if (LoginUser == 3)
$("#AdminMenu").attr('class', 'MenuCSS');
$("#UserMenu").attr('class', 'MenuCSSHide');
else {
$("#AdminMenu").attr('class', 'MenuCSSHide');
$("#UserMenu").attr('class', 'MenuCSS');
akee seth 12-Dec-12 0:35am
You should hide other menu before alert message. For better understanding, can u please post your ajax call?
Ganeshcse 13-Dec-12 4:02am
the menu is hide based on the login user again why should I hide again and again when ever I have alert message and I have many alert messages, for reference Please see above comment for code how I am hiding the div's

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi Ganeshcse,

Yes there is one way. I had the same problem faced in my project.
You can define one more javascript method before the service call and hide the div control that is been produced unexpectedly.

I am sharing my code with you for reference.

I had added the following code to hide the unwanted buttons during the popup show.

//Check sataus of the project and call javascript function for hide the unwanted button Image.
 if (CurrentDealStatus == Constant.REGISTRATION_REJECTED || CurrentDealStatus == Constant.PROJECT_WON || CurrentDealStatus == Constant.PROJECT_SAVE ||CurrentDealStatus==Constant.REGISTRATION_APPROVE ||  CurrentDealStatus==Constant.REQUIRES_REVISION)
ScriptManager.RegisterStartupScript(this, this.GetType(),"UserWaitingApprovalButtonHide", "<script type='text/javascript'>UserWaitingApprovalButtonHide();</script>", false);

The client script function is as follows.

function UserWaitingApprovalButtonHide() {

Like this you can also implement your code according to your need.

Ganeshcse 13-Dec-12 3:59am
Thanks Boss, yes I did in the same way but but not with js function just added a css attr like below

if (LoginUser == 3)
$("#AdminMenu").attr('class', 'MenuCSS');
$("#UserMenu").attr('class', 'MenuCSSHide');
else {
$("#AdminMenu").attr('class', 'MenuCSSHide');
$("#UserMenu").attr('class', 'MenuCSS');

however the div's which are hidden one are visible at the time of message box alert time that's it. Can we fix this also? Please share the code thanks
Master Black 13-Dec-12 5:02am
Yes you can. When you are calling the message box alert function, just before that statement call another function and inside that function you can hide the visible buttons.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100