Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We can use disabled to disable the form in the normal html.
<form disabled>
    <input type="text" name="name" value="" />
    <input type="submit" name="name" value="submit" />
</form>

But I want to disable the EditForm in blazor.

What I have tried:

I find it on the official docuement, but has no this parameter.
Posted
Updated 23-Mar-21 21:02pm

1 solution

Please, read this: html - How to enable/disable inputs in blazor - Stack Overflow[^]

Quote:
To disable elements you should use the disabled[^] attribute.

I've modified your code a bit and this will do what you're after. Blazor will automatically add or remove the disabled attribute based on the IsDisabled value.

You should use the disabled attribute on your button as well. It's a much better practice.
HTML
<button type="button" disabled="@IsDisabled"></button>
<input bind="@IsDisabled" type="checkbox" />

<input disabled="@IsDisabled" type="time" />

@code{
    protected bool IsDisabled { get; set; }
}
 
Share this answer
 
Comments
rtksmithjoton123 24-Mar-21 3:12am    
No, I want to disable it in the tag like <editform disable="">.
Maciej Los 24-Mar-21 3:20am    
So, what stops you to use "disabled" attribute?
Also, see solution provided by Peter Morris.
rtksmithjoton123 24-Mar-21 3:45am    
In this answer, every input box has the attribute `disabled`, but I want to set it only on <Editform>
Maciej Los 24-Mar-21 3:50am    
AFAIK, it's impossible. Strongly recommend to read answer provided by Peter Morris.
rtksmithjoton123 24-Mar-21 5:06am    
The document I have read.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900