Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Same page, different access - use Sessions?

Same page, different access - use Sessions?

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasephpasp-nettutorial
11 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maxdd 7
    wrote on last edited by
    #1

    I worked many time with PHP, and always used Sessions variables. For example: I have two users, with two different access level (lets say admin is 1 user is 2). The webpage as an ordinary table with information. Admin can view and edit, but user can only view. With PHP what I did is define the access level on a field (SQL table) of the table 'Users', and then, depending on the value of that field I do something like: index.php (..)

    if($_SESSION['level'] == 1)
    include(indexAdmin.php)

    if($_SESSION['level'] == 2)
    include(indexUser.php)

    Do you see the point? I need to do something similar with ASP.NET 3.5 C# coding, and I dont want to use and create groups on web.config. What can I do ?

    C D 2 Replies Last reply
    0
    • M Maxdd 7

      I worked many time with PHP, and always used Sessions variables. For example: I have two users, with two different access level (lets say admin is 1 user is 2). The webpage as an ordinary table with information. Admin can view and edit, but user can only view. With PHP what I did is define the access level on a field (SQL table) of the table 'Users', and then, depending on the value of that field I do something like: index.php (..)

      if($_SESSION['level'] == 1)
      include(indexAdmin.php)

      if($_SESSION['level'] == 2)
      include(indexUser.php)

      Do you see the point? I need to do something similar with ASP.NET 3.5 C# coding, and I dont want to use and create groups on web.config. What can I do ?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The session works somewhat the same, except instead of an include to pull in php code, you would actually write code to show the menu items you want to show.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      M 1 Reply Last reply
      0
      • M Maxdd 7

        I worked many time with PHP, and always used Sessions variables. For example: I have two users, with two different access level (lets say admin is 1 user is 2). The webpage as an ordinary table with information. Admin can view and edit, but user can only view. With PHP what I did is define the access level on a field (SQL table) of the table 'Users', and then, depending on the value of that field I do something like: index.php (..)

        if($_SESSION['level'] == 1)
        include(indexAdmin.php)

        if($_SESSION['level'] == 2)
        include(indexUser.php)

        Do you see the point? I need to do something similar with ASP.NET 3.5 C# coding, and I dont want to use and create groups on web.config. What can I do ?

        D Offline
        D Offline
        David Mujica
        wrote on last edited by
        #3

        If you are now developing an ASP.NET page, you can set the controls property, READONLY, to either true or false depending on the user's security. For example: If (user is admin) then Me.Textbox1.Readonly = False else Me.Textbox1.Readonly = True end if The other thing you can do is group the fields on a page inside a "Panel" and set it's Visible property to True/False. This will effectively remove the fields from the page. david

        M 1 Reply Last reply
        0
        • C Christian Graus

          The session works somewhat the same, except instead of an include to pull in php code, you would actually write code to show the menu items you want to show.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          M Offline
          M Offline
          Maxdd 7
          wrote on last edited by
          #4

          So I work on .aspx or on .aspx.cs?

          C D 2 Replies Last reply
          0
          • M Maxdd 7

            So I work on .aspx or on .aspx.cs?

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Depends. As someone else said, one possible way is to put items in panels in the aspx, and then show/hide them in the .cs file. If you were building a menu, I'd put it in a master page, and the items for that could well be added entirely in the cs file. It depends on what the specifics are of your task.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            M 1 Reply Last reply
            0
            • M Maxdd 7

              So I work on .aspx or on .aspx.cs?

              D Offline
              D Offline
              David Mujica
              wrote on last edited by
              #6

              You put the "me.textbox1.readonly=true" in the .aspx.cs. (I'm not sure of the C# syntax, my code behind is in VB)

              1 Reply Last reply
              0
              • C Christian Graus

                Depends. As someone else said, one possible way is to put items in panels in the aspx, and then show/hide them in the .cs file. If you were building a menu, I'd put it in a master page, and the items for that could well be added entirely in the cs file. It depends on what the specifics are of your task.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                M Offline
                M Offline
                Maxdd 7
                wrote on last edited by
                #7

                I have a GridView, with Insert, Delete and Edit options, (on TemplateFields) so I dont want these operations available for all users... how can I do that?

                C 1 Reply Last reply
                0
                • D David Mujica

                  If you are now developing an ASP.NET page, you can set the controls property, READONLY, to either true or false depending on the user's security. For example: If (user is admin) then Me.Textbox1.Readonly = False else Me.Textbox1.Readonly = True end if The other thing you can do is group the fields on a page inside a "Panel" and set it's Visible property to True/False. This will effectively remove the fields from the page. david

                  M Offline
                  M Offline
                  Maxdd 7
                  wrote on last edited by
                  #8

                  The problem is I have a GridView, with Insert, Delete and Edit options, (on TemplateFields) so I dont want these operations available for all users... just that.

                  P 1 Reply Last reply
                  0
                  • M Maxdd 7

                    I have a GridView, with Insert, Delete and Edit options, (on TemplateFields) so I dont want these operations available for all users... how can I do that?

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    I am not sure, you'll have to experiment. Those options go in the aspx usually, I'd try to see if they can be added in code, so you can do it conditionally.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    1 Reply Last reply
                    0
                    • M Maxdd 7

                      The problem is I have a GridView, with Insert, Delete and Edit options, (on TemplateFields) so I dont want these operations available for all users... just that.

                      P Offline
                      P Offline
                      Petr Pechovic
                      wrote on last edited by
                      #10

                      Hi, You can use this (as David above mentioned):

                      <asp:Panel runat=”server” ID=”pnlAdmin”>
                      … my admin section
                      </asp:Panel>

                      <asp:Panel runat=”server” ID=”pnlUser”>
                      … my common user section
                      </asp:Panel>

                      If (user is admin)
                      pnlAdmin.Visible = true;
                      else if (user is user) {
                      pnlUser.Visible = true;
                      pnlAdmin.Visible = false;
                      }

                      It’s easy but it’s not so excellent. Consider to read this article to get more info: http://ryangaraygay.com/blog/post/2008/04/PlaceHolder-and-Panel-Visibility-and-ViewState.aspx[^] Petr Pechovic

                      M 1 Reply Last reply
                      0
                      • P Petr Pechovic

                        Hi, You can use this (as David above mentioned):

                        <asp:Panel runat=”server” ID=”pnlAdmin”>
                        … my admin section
                        </asp:Panel>

                        <asp:Panel runat=”server” ID=”pnlUser”>
                        … my common user section
                        </asp:Panel>

                        If (user is admin)
                        pnlAdmin.Visible = true;
                        else if (user is user) {
                        pnlUser.Visible = true;
                        pnlAdmin.Visible = false;
                        }

                        It’s easy but it’s not so excellent. Consider to read this article to get more info: http://ryangaraygay.com/blog/post/2008/04/PlaceHolder-and-Panel-Visibility-and-ViewState.aspx[^] Petr Pechovic

                        M Offline
                        M Offline
                        Maxdd 7
                        wrote on last edited by
                        #11

                        Thank you very much to all :) Thanks for your pacience, I'm iniciating ASP.NET and there's a lot of things to learn so sometimes I know I could be a little :zzz: so please be pacience, I'm trying.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups