[英]Using C# and Blazor.... I want to be able to determine what the user selected
Here is my pretty simple C# code.这是我非常简单的 C# 代码。 Writing some software for my martial arts club
为我的武术俱乐部编写一些软件
Why do I get an error on this line为什么我在这条线上收到错误消息
HoldTechnique = Techniques.SelectedIndex.ToString();
it says它说
Techniques does not exist in current context
当前上下文中不存在技术
This is in my Terms.razor file:这是在我的 Terms.razor 文件中:
@page "/Terms"
<select id="Techniques" name="Techniques" runat="server" @onchange="MyVideoSrc">
<option>Shihonage</option>
<option>Kytenage</option>
<option>Kotegeshi</option>
<option>Tynohenko</option>
</select>
@code {
private void MyVideoSrc()
{
string HoldTechnique = "";
HoldTechnique = Techniques.SelectedIndex.ToString();
}
}
I did not get much help... well ... Actually no help at all from here.我没有得到太多帮助......好吧......实际上从这里根本没有帮助。 I just got: "....go look at some basic concepts before posting here...." I have coded for many years and I am just not familiar with How some of the stuff worked in C#/Html/Blazor.... I just wanted help with a little direction to get me pointed in the RIGHT direction.
我刚刚得到: “......在发帖之前先看看一些基本概念......”我已经编码多年,我只是不熟悉某些东西在 C#/Html/Blazor 中是如何工作的...... .. 我只是想帮助一点方向,让我指向正确的方向。 So for those who are starting out like I am .... If you are wondering it it actually pretty simple.
所以对于那些像我一样刚开始的人......如果你想知道它实际上很简单。 I have done a lot of work with Forms especially .NET/VB... if you have a basic select statement (mine has Japanese terms)
我已经用 Forms 做了很多工作,尤其是 .NET/VB ......如果你有一个基本的 select 语句(我的有日语术语)
<select @onchange="@DoStuff">
<option Value="Shihonage">Shihonage </option>
<option Value="Kytenage">Kytenage </option>
<option Value="Kotegeshi">Kotegeshi </option>
<option Value="Sankyo">Sankyo </option>
</select>
Here is your function to define your variables这是定义变量的函数
@functions
{
public string selectedString = "Ikyo";
}
Here is your code for "DoStuff" - eventually this will be a class.. Right now it is all in the .razor file这是您的“DoStuff”代码 - 最终这将是一个类..现在它都在 .razor 文件中
void DoStuff(ChangeEventArgs e)
{
selectedString = e.Value.ToString();
Console.WriteLine("It is definitely: " + selectedString);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.