【问题标题】:How to realise ComboBox in .cshtml ASP.NET如何在 .cshtml ASP.NET 中实现 ComboBox
【发布时间】:2021-11-17 21:50:51
【问题描述】:

不工作 asp:DropDownList . . . . . . . . . . . . ... . …… .

。 .. .. View result

使用 Layout = "_Layout.cshtml" 添加.cshtml

 @section Head{
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="~/css/make-ad.css" rel="stylesheet" />
        <title>Document</title>
    
    <form asp-controller="Item" asp-action="Add" method="post">
        <label> Category</label>
        <input asp-for="CategoryId" type="text" />
    
        <asp:DropDownList class="ddlstyle"ID="DropDownList1" runat="server" >  
            <asp:ListItem Value="">Please Select</asp:ListItem>  
            <asp:ListItem>New Delhi </asp:ListItem>  
            <asp:ListItem>Greater Noida</asp:ListItem>  
            <asp:ListItem>NewYork</asp:ListItem>  
            <asp:ListItem>Paris</asp:ListItem>  
            <asp:ListItem>London</asp:ListItem>  
        </asp:DropDownList>  
        <button type="submit">
            Add
        </button>
    </form>

【问题讨论】:

  • 您不能混合使用网络表单和剃须刀。

标签: asp.net razor


【解决方案1】:

试试这个 html5 ddl,而不是 web 表单 asp.net

<select  id="DropDownList1">
  <option value="">Please Select</option>
  <option value="Greater Noida">Greater Noida</option>
  <option value="NewYork">NewYork</option>
  <option value="Paris">Paris</option>
</select>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-02
    • 2011-11-12
    • 1970-01-01
    • 2014-06-11
    • 1970-01-01
    • 2019-05-04
    • 2010-11-06
    • 1970-01-01
    相关资源
    最近更新 更多