I’ve got a page with a couple dozen (dynamically changeable amount) input fields (mostly text, a few buttons), and when the form is complete/submitted/finalized, it can no longer be edited but can still be viewed. What I did to accomplish this is to declare a string called disabled, and if the form has been finalized, it is set as
disabled="disabled=\"disabled\""
and otherwise is null. I then place it in evey input tag, so that they will be disabled. This works fine. However, the cursor still changes to a pointer on the buttons and a text cursor on the text boxes. How can I change that? I’m trying with
string disabled = (bool)ViewData["Finalized"] ? "disabled = \"disabled\" style=\"cursor:default\"" : null;
which renders the quotes within the tags as ". The disable feature works fine, but the cursor is unaffacted.
I’ve tried rewriting it with single quotes within the string (same result), and with single quotes around the string and double quotes within it (error, too many characters in literal), but have had no success.
Is this something that can be done this way? Or am I going about it in the wrong way?
The resulting output of the above setup is
<input maxlength="4" type="text" name="input1" value="1" disabled = "disabled" style="cursor:default"/>
Forgot to mention, inputs are defined on the page along the lines of this example:
<input type="button" id="newtablebutton" class="pctbutton white" value="Add Table" onclick="showbox()" <%: disabled %> />
So the output is exactly this?
You disabled string is getting html encoded when it’s set on the element. The reason is the way you’re setting it onto the element.
Change this:
To this:
… and you should be good. The reason is that <%: disabled %> html encodes and <%= disabled %> does not.