Web Forms :: Enable / Disable User Controls In Master Page
Oct 7, 2010
I have a user control in my Master page and need to be able to Enable/Disable it from ANY page. How is this done? My user control has a few TextBox fields and a button. I was hoping to set a public property and simply Enable/Disable, but public properties seem to only work on the Master page code behind and not other pages.
I have table called ROLE with fields (id,name,permission) example values (1001,madhu,hr)
I have another table called LOGIN with fields(id,DOB,password) example values(1001,24101989,madhukumar)
What i want is , if i login using the LOGIN table ,it check the id and permission in the ROLE table , if the permission is 'hr' it enable to access the menu , or if the permission is any other it just print the error message ("no permission")
Note: menu is placed in master page , but login is not in the master page ...
I am looking to enable/disable controls (TextBox, DropDownList, etc.) in a GridViews template column based on the users specific access level when the user clicks the edit button. I have tried the following two methods:
I want to enable/disable controls of a asp.net page against a logged in user's permission. say 'admin' & 'hr' can change user's birth date text-box in a page but others will see the text-box as disabled.
iam using masterpage and sitemap in my project, what i want to is that if user login is did, based on the user previlage in need to show the sitemap menu page if user i have the previlage to see the page then i should enable that page otherwise i need disable that page
i am working in asp.net and csharp, we have 10 user, but certain user only need to put dataentry. how to enable and disable based on the user to access certain form ,like add, modify view options.
The following code works fine for disabling content page controls, but how do I disable master page controls?
public void DisableControls(Control control,bool isEnable) { if (control.HasControls()) { foreach (Control c in control.Controls) { DisableControls(c, isEnable); } } else { if (control is IPostBackDataHandler && !(control is IPostBackEventHandler)) { if (control is WebControl) { ((WebControl)control).Enabled = isEnable; } else if (control is HtmlControl) { ((HtmlControl)control).Disabled = !isEnable; } } } }
I'm trying to enable/disable buttons in my gridview according to a value in gridview's field. But everytime when I try to run my page, it shows me below underlined error and point to my gvTimeSheet.DataBind() in page_load.
"Unable to cast object of type 'System.EventArgs' to type 'System.Web.UI.WebControls.GridViewRowEventArgs'." I also tried to enable / disable button in HTML but it just against from what I need it to be.
Example, sheet_status = true, I do not need to enable the button.
I have a gridview that is built based on my objectdatasource.. so at the moment, i have 1 gridview linked to 3 different objectdatasource resultsets.. my question is.. only 1 of the 3 do i want to allow or should i say enable the "GridView1_SelectedIndexChanged" ability. Is that possible, that when i bind the datasource to the gridview for that one, i can enable that?
I am new to asp development but have been around c# for a while. Basically I am trying to create a page which will pull data from a database and then for each object it creates I would like to add a user control which is built to represent that object. So basically I have tried quite a number of things to get it to work but for some reason I can't figure it out! How can I programmably add user controls and then set their properties from a 'master' page which hosts the user controls?
On content page (Login.aspx), I got Uesr Type. For Admin type only, I need to show the above bold menu item. No problem for getting User Type as "Admin". Just problem is that, how to visible/in-visible or enabled/disabled above bold text menu item?
Have a gridview that is populated via a DB, which is populated by another tool. That tool records all the data, including the user that submitted it.
The site also enables editing, but I want only the user that submitted the data to have the ability to edit HIS data only, even though the grid view is displaying other people's datas.
So currently the gridview has "ShowEditButton="True"
So on the far left, there is the Edit option for all lines, for all users, for any user viewing the site.
I am working with the master pages which contain the Manu control. I want to disable the few menuItems from the master page's Menu control in the child form. I have tried so many times but I only succeded to disable the whole menu of master page, but my sanerio is different. I have to disable only few MenuItems from Menu and also want to disable few Items of Submenu
I have at present two master pages, what I want to achieve is the following; One user control loads, there is a button to click, when user clicks that button the user control should unload upon session authentication and the second one loads. However, the second one has a button as well, and I want to click on that button to unload that control from master page and reload the first user control.
I have user control which is attached to one master page in one of the content placeholers ,but when I create the content pages ,I cannot see the user control,that's why I manually write in every content page