locked
How to hide the asp control using asp.net C# web forms RRS feed

  • Question

  • User-471420332 posted

    I have around 11 section in my tab every section have around 50 question, then total all question will be around 550 question. There two users will access this tab, one user will see all question and they will submit details of all sections and another user will see some questions around 200 question from each section.

    My question is how to hide the questions to another user will have some questions access and i am user asp.net control in all 11 sections but i am not getting any best approach to hide the question to another user.

    below is my sample tab section

    enter image description here

    When I click Case 1 section then case1.aspx page will appear with 50 question to full access user and another user will have 20 question access only in case1. and this is not jquery tabs using user control doing this. My question is how to hide 30 question for another user in case1 section, i am planing to used asp panel to hide 30 questions in case similarly in other sections. This is correct way to hide question. any other simple trick also there?

    Because in case 1 section another user can see question number 1 to 10 and 40 to 50 and total 20 question. If i will used asp panel then question number sequence problem also coming to me like 1,2,3,4,5,6,7,8,9,10,40,41,42...50. And the sequence should be 1,2, ....20. Please tell me i have to use asp.net panels or not, if not please tell be best trick.

    Saturday, June 22, 2019 6:06 PM

All replies

  • User475983607 posted
    The database design should return the appropriate records for each user role.
    Saturday, June 22, 2019 8:37 PM
  • User409696431 posted

    I agree with what mgebhard said.

    This assumes your questions are in a database, not hard coded into the page.  In the database, add a column in the table storing the questions that indicates what role(s) should see the question - user1role, allusers, etc..  Use the user's role as a parameter when fetching the questions to put on the page.  If the sequence number of the question is also stored in that database, you'll need to decide if you want to store multiple sequence numbers to display, choosing which one based on the user's role, or if you want to keep the question number in the database independent of the displayed sequence number and programmatically generate the displayed sequence number as the questions are bound to the control.

    Saturday, June 22, 2019 9:34 PM
  • User-471420332 posted
    my questions are hard coded, not in database, please tell me how to manage hard coded questions.
    Sunday, June 23, 2019 4:54 AM
  • User409696431 posted

    If they are hard coded, you can hide or display sections of the page based on the user role (put them in controls with an id, and set visible to true or false when loading the page), but what complicates the problem is that you want the sequence numbers to change based on how many questions the user sees and those numbers are also hard coded.   If you have only two cases, well, frankly the simplest thing to do is to copy the page to a second page, leave only the questions the second role can see, numbered appropriately, and in both pages check the role of the user on page load and redirect to the correct form based on that role.

    Sunday, June 23, 2019 11:28 AM
  • User475983607 posted

    my questions are hard coded, not in database, please tell me how to manage hard coded questions.

    Given the clarifying information, questions are hard-coded, I agree with Kathy.  Craft page(s) specifically for each type of user and redirect to the appropriate page.

    Sunday, June 23, 2019 4:50 PM