-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot bind value of element and have onchange event fire. Can only have either or. #15882
Comments
Yes,
|
Appreciate the hint but haven't figured this out yet. How would I access the uiLocation if I can't bind it to the select html control? Seems like a chicken/egg scenario if you can't bind a value and call an event trigger on the same element. I find this to be rather limiting, but i assume I am just missing something. If I can't have bind and have an onchange for a single dropdown then I need to figure out a way to call an event and reference the selected value of a dropdown within that event. Similar to old school asp webforms where the controls were server side. I haven't seen this ability yet but admittedly I'm still learning it. |
Looking at your suggestion again, it looks like if I set the value of uiLocation, it would then set the selected value of the dropdown without me needing the bind keyword. Clever. |
You don't need JS interop for this, but you do need to store The way I approached this (well, in my case, it was for radio buttons, not a drop-down, but same difference) was to create a component There's no JS involved it (though there might be if I would use, say, visual effects from a JS library), but there's a fair bit of C# boilerplate involved still. |
We are still evolving the "bind" APIs, so over time this might change depending on what people report, but right now there's a better way of achieving your goal. Instead of using This doesn't require resorting to any JS interop. Example:
|
I made a workaround for this by creating a method that sets the value of the inputModel:
|
Seems like a function what I am needing... care to elaborate what packages/addons needed to be used for getting those params? If i try to use this i am getting something like that: The type or namespace name 'TValue' could not be found (are you missing a using directive or an assembly reference?) |
<select id="cboLocations" bind="@uiLocation" onchange="@loadforms">
<option value="A">A_</option>
<option value="B">B_</option>
<option value="C">C_</option>
<option value="D">D_</option>
</select>
@functions {
string uiLocation =""
protected async void LoadForms()
{
// does an async call relying on the value of uiLocation variable
}
}
The text was updated successfully, but these errors were encountered: