简体   繁体   English

使用 C# 和 Blazor .... 我希望能够确定用户选择了什么

[英]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.

相关问题 我有一个C#Windows窗体应用程序,希望用户能够安排重复任务 - I have a C# Windows Forms Application and I want the user to be able to schedule a recurring task 在带有HTML表格的网页上,如何确定是否使用C#选择了HTML行? - On a web page with Html Table, how do I determine if a Html Row is selected or not using c#? 如何在不使用 Blazor 中的绑定的情况下确定下拉列表中的选定值? - How can I determine selected value in dropdown without using bind in Blazor? Blazor 服务器端:如何读出用户/浏览器的本地时间而不是服务器的本地时间(仅使用 c#) - Blazor Server Side: How can I read out the local time of the user/browser not of the server (using only c#) 我想在侧面导航栏 blazor C# 中分层显示类别 - I want Display Categories in hierarchical in side navigation bar blazor C# 我想使用C#中的Selenium从ID和行动态更改的列表中删除用户 - I want to delete a user from a list that ID's and rows change dynamically using Selenium in C# 我希望能够使用 id 或用户名验证登录表单,同时使用 c# 从 mysql 数据库中获取数据 - i want to be able to validate a login form with an id or username, while getting the data from mysql database using c# 我想将 Javascipt object 传递给 c# 方法而不在 Mono 或 Z98AD8B3C99B3CA416F1F7FA84FEE 中序列化 - I want to pass Javascipt object to c# method without serialization in Mono or Blazor 我无法使用 c# 和 MS Access DB 过滤当前用户记录 - I connot able to filter the current user record using c# and MS Access DB 确定是否在C#ComboBox中选择了项目 - determine if item is selected in C# ComboBox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM