This topic is locked

Disable fields based on log-in

2/14/2008 6:38:41 AM
ASPRunnerPro General questions
D
dlangham author

Hi,
I would like to be able to disable certain fields based on a log-in username, I do not want to hide these fields but just make them not editable or able to add them.
Has anyone done this before, I am using Version 5.1
Regards

Dale

Sergey Kornilov admin 2/15/2008

Dale,
you can use insert ASP code snippet function to insert your code at the end of page.

In this function you apply your business logic and make certain fields disabled using Javascript.
Example:

if Session("UserID")<>"admin" then

Response.Write "<script>document.editform.value_FieldName.disabled=true;</script>"

end if

D
dlangham author 2/16/2008

Dale,

you can use insert ASP code snippet function to insert your code at the end of page.

In this function you apply your business logic and make certain fields disabled using Javascript.
Example:


Hi Sergey,
I have tried this with the latest version and for some reason it will not work at all, I have tried it on numerous pages, but still cannot make it work...any ideas?

J
Jane 2/19/2008

Dale,
it's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and post a URL to your pages here or send it to [email=support@xlinesoft.com]support@xlinesoft.com[/email] along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.

S
soberholtzer 2/19/2009

Jane,
I have copied the asp code snippet from this post, and it worked to disable the field. However, I need to actually hide the field, not just display it. I only want two users to be able to add, edit, and view the field Rate. I have included this code on the add, edit, and list pages. I want to hide the field from all users except two. Please help.
Sean
[codebox]if Session("UserID")<>"chollywood" then

Response.Write "<script>document.editform.value_Rate.disable=true;</script>"

end if[/codebox]

J
Jane 2/20/2009

Hi,
to hide fields on the edit page use Edit page: Before display event on the Events tab.

Here is a sample:

if Session("UserID")<>"chollywood" then

xt.assign "Rate_fieldblock",False

end if

S
soberholtzer 2/20/2009

Jane, Thank you! Works great.
A follow up.....How would I add another user. In the above code, it is userid<>"chollywood". How would I code it if I wanted userid<>"chollywood" and "Tyarber".
Essentially, I want two people to be able to view that field, but no others.
Thanks again!

Sergey Kornilov admin 2/20/2009

Try this:

if Session("UserID")<>"chollywood" and Session("UserID")<>"Tyarber" then

xt.assign "Rate_fieldblock",False

end if
S
soberholtzer 2/20/2009

That did not work. It kept the field hidden for the second user Tyarber. It still showed the field as displayed and editable for the first UserID "chollywood".

L
luic 2/20/2009

I have similar requirement but slightly different.
I have two input fields, one is a drop-down and the other one is a text input field. If the drop-down value equals to "In-active", I want the text input field hidden. But if the drop-down value equals to "active", I want the text input field appear.
How can I do this in version 6?
Chris.