This topic is locked

Unable to Disable Date Field

5/10/2011 6:42:33 AM
ASPRunnerPro General questions
M
MrDerp author

We have a number of different users with varying levels of access to certain screens/fields. In order to restrict the editing of a particular field,I am using the following ASP custom code:



if Session("GroupID")="Sup" then

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

end if


This works fine for the majority of fields but does not disable a date field using dropdown boxes and datepicker.
Do you know of any way of completely disabling this? I still want the user with restricted rights to be able to view the field, but they must not be able to make any changes.
Many thanks.

Sergey Kornilov admin 5/10/2011

You need to use Javascript API for this purpose:

http://xlinesoft.com/asprunnerpro/docs/ctrl_setdisabled.htm

M
MrDerp author 5/11/2011



You need to use Javascript API for this purpose:

http://xlinesoft.com/asprunnerpro/docs/ctrl_setdisabled.htm


I am currently using ASPRunner v6.1 (as newer versions do not work properly with Informix). I've had a look at the documentation but I can't see any reference to the Javascript OnLoad event - is this not available in v6.1? If not, what other options do I have?

Sergey Kornilov admin 5/11/2011

Javascript API is not available in version 6.1. You can do the same using plain Javascript however you need to disable each dropdown box and datepicker separately. Find a name of each control that is part of date edit control and disable it separately.

M
MrDerp author 5/11/2011

Thanks. I've managed to disable each dropdown box but I can't seem to disable the datepicker. I've looked at the source for the edit page and can see that I need to disable the following:
dayvalue_date

monthvalue_date

yearvalue_date

tsvalue_date
However, the datepicker icon is still functioning!

Sergey Kornilov admin 5/11/2011

Unfortunately it won't work the same way with datepicker in version 6.1 since this is not an edit control and doesn't have an ID.
Probably the best you can do is to hide this edit control all together.

Here is the article that provides sample code:

http://xlinesoft.com/asprunnerpro/docs/hide_controls_on_add_edit_pages.htm

M
MrDerp author 5/12/2011

I've managed to get around this by just having dropdown boxes and no datepicker.
However, the plot thickens! When editing a record, there are some disabled fields that are deleting their contents when I save a record. It doesn't seem to be affecting every disabled field, just a select few. Is there any way to ensure that the contents are retained when saving?

Sergey Kornilov admin 5/12/2011

Probably you should not disable tsvalue_date field. Not sure what else I can suggest without seeing your application.