Click here to Skip to main content
15,886,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends, I have small doubt in asp.net 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

this?

Please any one can help me with this problem


Thanks & Regards
Ganesh
Posted
Comments
vishal jodh 11-Dec-12 23:45pm    
pls past u r java script code so i can understand better
Ganesh KP 13-Dec-12 3:59am    
if (LoginUser == 3)
{
$("#AdminMenu").attr('class', 'MenuCSS');
$("#UserMenu").attr('class', 'MenuCSSHide');
GetAllItemsOnLoad();
}
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?
Ganesh KP 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

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.

VB
//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.

C#
function UserWaitingApprovalButtonHide() {
    $("#dvSave").hide();
    $("#dvSaveSubmit").hide();
    $("#dvClaimDiscount").hide();
    $("#dvApproveWon").hide();
    $("#dvAddProduct").hide();
    $("#dvReject").hide();
    $("#dvApprove").hide();
    $("#dvRevisebtn").hide();
}


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

Thanks
 
Share this answer
 
Comments
Ganesh KP 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');
GetAllItemsOnLoad();
}
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
[no name] 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)



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