Skip to content

Change value of HTML select element #275

Answered by egil
dawidr asked this question in Q&A
Discussion options

You must be logged in to vote

OK, I can confirm that this works:

CUT:

<select id="pageSize" @bind="Size">
    <option value="5">5</option>
    <option value="10">10</option>
    <option value="20">20</option>
    <option value="50">50</option>
    <option value="100">100</option>
</select>

@code 
{
    private int _size = 10;

    [Parameter]
    public int Size
    {
        get
        {
            return _size;
        }
        set
        {
            if (_size != value)
            {
                _size = value;
                SizeChanged.InvokeAsync(value);
            }
        }
    }

    [Parameter]
    public EventCallback<int> SizeChanged { get; set; }
} 

Test:

[Fact]
public void ComponentShouldChan…

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@egil
Comment options

egil Dec 2, 2020
Maintainer

@dawidr
Comment options

@dawidr
Comment options

@egil
Comment options

egil Dec 2, 2020
Maintainer

Comment options

You must be logged in to vote
2 replies
@egil
Comment options

egil Dec 3, 2020
Maintainer

@sc-dawidrutkowski
Comment options

Answer selected by egil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants