|
-
Sep 27th, 2005, 03:41 PM
#1
Thread Starter
New Member
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:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<script language="vb" runat="server">
public sub Page_Load(sender as object, e as eventargs)
MAN_INVOICE_DATE.Text = format(system.datetime.now,"dd-MMM-yy")
CREATION_DATE.Text = format(system.datetime.now, "dd-MMM-yy")
SYS_INVOICE_DATE.Text = format(system.datetime.now, "dd-MMM-yy")
[B]CLIENT_ID.Attributes.Add("onchange","javaScript:this.value = this.value.toUpperCase();")
Dim levelAccess As HttpCookie = Request.Cookies("levelAccess")
Dim userLevel As Byte
userLevel = levelAccess.value
Dim ccmReadOnly as Boolean
Dim dcmReadOnly as Boolean
Select case userLevel
Case 1
ccmReadOnly = "False"
dcmReadOnly = "False"
Case 2
ccmReadOnly = "True"
dcmReadOnly = "False"
Case 3
ccmReadOnly = "True"
dcmReadOnly = "True"
End Select[/B]
end sub
</script>
<html>
<head></head>
<body>
<form method="post" name="form1" runat="server">
<table>
<tr valign="baseline" bgcolor="#99CCFF">
<td align="right" nowrap bgcolor="#99CCFF">CCM Email</td>
<td bgcolor="#99CCFF"><asp:TextBox ID="CCM_EMAIL" TextMode="SingleLine" ReadOnly="<%# response.write(ccmReadOnly) %>" Columns="32" runat="server" />
</td>
<td align="right" nowrap="nowrap">CCM Approval Date</td>
<td><asp:TextBox ID="CCM_DATE" TextMode="SingleLine" ReadOnly="<%# response.write(ccmReadOnly) %>" Columns="8" runat="server" />
</td>
</tr>
</table>
</form>
</body>
</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!
-
Sep 27th, 2005, 03:50 PM
#2
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....
-
Sep 27th, 2005, 03:51 PM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Sep 27th, 2005, 03:55 PM
#4
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
-
Sep 27th, 2005, 04:13 PM
#5
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|