Results 1 to 5 of 5

Thread: READONLY based on cookie value...

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    READONLY based on cookie value...

    I am very new to .NET, so forgive my ignorance.

    I am probably approaching this in every wrong direction, but for right now, until i can get a real user authentication scheme going (not to mention having to learn how to use code behind...) this will have to do.

    Basically, I have an application that has 3 different user levels. The user shall login and the user/pass verified against an Oracle db. If it comes back good, a cookie is set that specifies the user access level. This app will be used on our intranet, and mostly by people who are not going to mess with cookies, so I am not worried about total security (yet... I just need to get this thing out the door for now, and go back and add aforementioned proper user access later).

    Sooo... all that to say that I need to have certain field in a form READONLY depending on the user level captured in the cookie. Here is what I have so far (most of the code removed, only displaying one row...):


    VB Code:
    1. <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
    2. <script language="vb" runat="server">
    3. public sub Page_Load(sender as object, e as eventargs)
    4. MAN_INVOICE_DATE.Text = format(system.datetime.now,"dd-MMM-yy")
    5. CREATION_DATE.Text = format(system.datetime.now, "dd-MMM-yy")
    6. SYS_INVOICE_DATE.Text = format(system.datetime.now, "dd-MMM-yy")
    7. [B]CLIENT_ID.Attributes.Add("onchange","javaScript:this.value = this.value.toUpperCase();")
    8.    Dim levelAccess As HttpCookie = Request.Cookies("levelAccess")
    9.    Dim userLevel As Byte
    10.    userLevel = levelAccess.value
    11.    Dim ccmReadOnly as Boolean
    12.    Dim dcmReadOnly as Boolean
    13.  
    14.    Select case userLevel
    15.     Case 1
    16.         ccmReadOnly = "False"
    17.         dcmReadOnly = "False"
    18.     Case 2
    19.         ccmReadOnly = "True"
    20.         dcmReadOnly = "False"
    21.     Case 3
    22.         ccmReadOnly = "True"
    23.         dcmReadOnly = "True"
    24.     End Select[/B]
    25.    
    26. end sub
    27. </script>
    28. <html>
    29. <head></head>
    30. <body>
    31. <form method="post" name="form1" runat="server">
    32. <table>
    33.  <tr valign="baseline" bgcolor="#99CCFF">
    34.   <td align="right" nowrap bgcolor="#99CCFF">CCM Email</td>
    35.   <td bgcolor="#99CCFF"><asp:TextBox ID="CCM_EMAIL" TextMode="SingleLine" ReadOnly="<%# response.write(ccmReadOnly) %>" Columns="32" runat="server" />    
    36.   </td>
    37.   <td align="right" nowrap="nowrap">CCM Approval Date</td>
    38.   <td><asp:TextBox ID="CCM_DATE" TextMode="SingleLine" ReadOnly="<%# response.write(ccmReadOnly) %>" Columns="8" runat="server" />          
    39.   </td>
    40.  </tr>
    41. </table>
    42. </form>
    43. </body>
    44. </html>

    With or without the quotes around the response.write, I get the following error:
    BC30451: Name 'ccmReadOnly' is not declared.

    Thanks for your help!

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: READONLY based on cookie value...

    This may not make a bit of difference, but you don't need the quotes for True and False.. its a Boolean, and True And False are the only options.. not a "string named false" or a "string named true"

    ... just saw your post about the "with or without quotes does the same thing".. so never mind....

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: READONLY based on cookie value...

    Moved from VB.NET forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: READONLY based on cookie value...

    It's your variables.. they only exist within the sub because of your declarations... once the sub is exited, they disappear... Need to declare the booleans outside the sub... im guessing... never really messed with vb scripting

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    Re: READONLY based on cookie value...

    I see what I did wrong witht he variables, and cannot believe I tried to call that variable from outside the sub. Duh.

    So now I am presented with another error:

    Compiler Error Message: BC30491: Expression does not produce a value.

    Source Error:
    Line 278: <td bgcolor="#99CCFF"><asp:TextBox ID="CCM_EMAIL" TextMode="SingleLine" Columns="32" ReadOnly="<%#response.write(ccmReadOnly)%>" runat="server" />

    The expression it is referring to, according to the detailed report, is:

    target.ReadOnly = CType(response.write(ccmReadOnly),Boolean)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Still playing with the code - hoping the ASPX God will smile upon me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width