# Read-only asp:textbox and JavaScript

**URL:** <https://discuss.workflowgen.com/t/read-only-asp-textbox-and-javascript/151>\
**Category:** Visual Studio Web Forms\
**Created:** [October 29, 2007, 6:31am UTC](https://discuss.workflowgen.com/t/read-only-asp-textbox-and-javascript/151 "2007-10-29T06:31:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [October 29, 2007, 6:31am UTC](https://discuss.workflowgen.com/t/read-only-asp-textbox-and-javascript/151/1 "2007-10-29T06:31:23Z")

</div>

### Issue

I have a read-only `asp:textbox` in my form whose the contents change by means of client-side JavaScript. When the form is submitted, the textbox’s contents are lost, probably because it’s read-only. Is there a way to have the textbox’s contents remain intact?

### Cause

Unlike values for disabled controls, read-only control values are submitted with the form data set. However, it is at this point that WorkflowGen identifies the field as read-only and does not accept the value, regardless of how the contents were entered or altered on the form. Whether the form element is defined as read-only in WorkflowGen or within the form itself, the behavior is the same.

### Solution

Add the following JavaScript code to your `asp:textbox`:

```auto
onfocus=this.blur() onclick=this.blur()

```

This will prevent the textbox from getting the focus (cursor) should the user try clicking in it or by means of the `Tab` key (Tab Index).
