Does Microsoft Net Core 3 recommend method syntax or query syntax for Linq Entity Framework queries? This is a debate in our workplace, we are curious.

enter image description here

I want to get data from table on the behalf of foreign key in a single view. I created a table which stores my headings and I created another table to store sub_headings. I created a relationship with foreign key. Know I want to get data from these tables. I already stored data in the database - how to retrieve it?

<div class=" col-md-4">
<div class="other-feature-item">
   This part I need from heading table
       <h4>heading</h4>

   This part I need from sub_heading table with above heading _id

   <ul style="list-style-type:circle;margin-left: 15px">
   <li>sub_heading1</li>
   <li>sub_heading2</li>
   </ul>
</div>
</div>

enter image description here

Failed to create file "obj\Debug\netcoreapp2.2\WebCore.AssemblyInfo.cs". The request is not supported

<WriteCodeFragment AssemblyAttributes="@(AssemblyAttribute)" Language="$(Language)" OutputFile="$(GeneratedAssemblyInfoFile)">

In this i have got the result till reportviewer in webpage, but i couldt get RDLC search textbox fixed

saw from a site which uses stores procedure , where as i am try with sql query in web form.

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        this.BindRDLCReport();
    }
}
private void BindRDLCReport()
{
    ReportViewer1.ProcessingMode = ProcessingMode.Local;
    ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report1.rdlc");
    salesDataSet dsINventory = GetData("SELECT  * FROM inventory WHERE product = @product OR @product = ''");
    ReportDataSource datasource = new ReportDataSource("salesDataSet", dsINventory.Tables[0]);
    //ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(datasource);
}
private salesDataSet GetData(string query)
{
    SqlCommand cmd = new SqlCommand(query);
    //using (SqlConnection con = new SqlConnection(salesConnectionString))
    {
        using (SqlDataAdapter sda = new SqlDataAdapter())
        {
            cmd.Connection = con;
            cmd.Parameters.AddWithValue("@product", TextBox1.Text);
            sda.SelectCommand = cmd;
            using (salesDataSet dsINventory = new salesDataSet())
            {
                sda.Fill(dsINventory, "DataTable1");
                return dsINventory;
            }
        }
    }
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
    BindRDLCReport();
}
}

i expect to get the row in the reportviwer.

I am working on ASP.NET C# Web application that has around 50 fields divided on four different tabs.On the fourth tab I have submit button which will submit that data in the database.

My query is that I have done validation through jquery plugin as well as with asp.net validation controls. So when JavaScript is turned off,server side validation through validation control is running properly. But when JavaScript is on,My application is getting validated twice and I am getting error message from both j query plugin validation and server side validation.

So is there any way I can make sure that if jquery validation is taking place then I dont want server side validation to take place.

If I remove the error message from Server side validator controls and check page.isvalid in code behind file and is not valid then I print common error message for all.But if I want to have error message for all individual fields then I get two error messages for single text box.

Is there any way I can find out that jquery validation has not happened so please execute all server validation else execute. And if I allow both the validations to take place then I want error message to be printed only once.

I tried to build a Autocomplete textbox in cshtml, i have tried the following code but it is not working. The controller part have no error during debugging, not sure which part am i missing. Appreciated for any help.

Controller

[HttpPost]
       public JsonResult Index(string Prefix)
       {
           //Note : you can bind same list from database  
           List<CardHolderDetails> ObjList = new List<CardHolderDetails>()  
           {  

               new CardHolderDetails {CardId=1,UnitNo="Latur" },  
               new CardHolderDetails {CardId=2,UnitNo="Mumbai" },  
               new CardHolderDetails {CardId=3,UnitNo="Pune" },  
               new CardHolderDetails {CardId=4,UnitNo="Delhi" },  
               new CardHolderDetails {CardId=5,UnitNo="Dehradun" },  
               new CardHolderDetails {CardId=6,UnitNo="Noida" },  
               new CardHolderDetails {CardId=7,UnitNo="New Delhi" }  

       };
           //Searching records from list using LINQ query  
           var CityList = (from N in ObjList
                           where N.UnitNo.StartsWith(Prefix)
                           select new { N.UnitNo });
           return Json(CityList, JsonRequestBehavior.AllowGet);
       }  

CSHTML

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#UnitNo").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: "/Home/Index",
                    type: "POST",
                    dataType: "json",
                    data: { Prefix: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.UnitNo, value: item.UnitNo };
                        }))

                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        });
    })
</script>
@using (Html.BeginForm())  
{  
   <div class="form-group">
          @Html.EditorFor(model => model.UnitNo, new { htmlAttributes = new { @class = "form-control", id = "UnitNo" } })
   </div> 
} 

The value return is not showing in autocomplete form.

I have a problem with Razor that when I invoke the helper @EditorFor (), the result in the HTML generates an with the name and id attribute with different values each.

 <div class="form-group">
            @Html.LabelFor(model => model.OCRDSAPF2.CardName, "Cliente", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10"> 

            @Html.EditorFor(model => model.OCRDSAPF2.CardName, new { htmlAttributes = new { @class = "form-control", @onBlur = "completarCodigo()", @value = "@ViewBag.cliente" } })               
                    <script type="text/javascript">
                        $("#OCRDSAPF2_CardName").autocomplete({
                            source: function (request, response) {
                                $.ajax({
                                    type: 'POST',
                                    url: '@Url.Action("getClientes", "Cotizacions")',
                                    data: { term: $("#OCRDSAPF2_CardName").val() },
                                    datatype: "json",
                                    success: function (result) {
                                        response(result);
                                    }
                                });
                            }
                        });
                    </script>
                    <strong>
                        @Html.ValidationMessageFor(model => model.OCRDSAPF2.CardName, "", new { @class = "bg-danger" })
                    </strong>
                </div>
        </div>

the output html:

<input class="form-control text-box single-line ui-autocomplete-input" data-val="true" data-val-required="ERROR:El campo Cliente no puede estar vacio." id="OCRDSAPF2_CardName" name="OCRDSAPF2.CardName" onblur="completarCodigo()" type="text" value="" autocomplete="off">

I want:

<input class="form-control text-box single-line ui-autocomplete-input" data-val="true" data-val-required="ERROR:El campo Cliente no puede estar vacio." id="OCRDSAPF2_CardName" name="OCRDSAPF2_CardName" onblur="completarCodigo()" type="text" value="" autocomplete="off">

sorry my English

My company is trying to setup some guidance on which technology to use for building applications. In doing my research I am getting confused.

It seems there are 3 ASP.NET technologies.

  1. MVC
  2. Razor
  3. Razor Pages

MVC is fairly clear to me as it has been around for a long time.

But I am getting confused between Razor and Razor pages. I can find lots of info on Razor Pages, but limited stuff that will compare them.

We are looking to target ASP.Net Core. So my questions are:

  1. Is Razor in ASP.NET Core?
  2. If so, is Razor "old" tech compared to Razor Pages? (Meaning does Razor Pages replace Razor?)
  3. What caused the need to build Razor Pages (instead of just building on Razor)?

This question already has an answer here:

I am trying to get an order by from a value that comes back from a database. We have a Linq in our View's Razor code that pulls a DropDownListFor(x => x.myValues) and hoping we can get an order by because it is a combination of alpha text and numeric values in the string. We want to order by the numeric values. I am trying to figure out the best way to do this and in the order it would be done.

Substring then OrderBy? Or other way?

I have an example of my data and the

The data that comes as:

monthly-10-donation
monthly-100-donation
monthly-1000-donation
monthly-15-donation
monthly-150-donation
monthly-1500-donation
monthly-20-donation
monthly-200-donation
monthly-2000-donation
annual-10-donation
annual-100-donation
annual-100-donation
annual-15-donation
annual-150-donation
annual-1500-donation

But I would like to order them by the 'monthly' or 'annual' like they are now BUT then order them by correct numeric order.

Because the values are just outputted on an DropDownListFor() the Razor code is fairly simple.

  @Html.DropDownListFor(model => model.SubscriptionPlanCode, Model.SubscriptionOptions, new { @class = "donation-subscription-select" })

So this may be where I want to do the ordering. I guess I could do it in the Controller, but for now, I would am seeking some help on the View/Razor side for the order by monthly/annual, then the numeric values for each grouping.

Thanks in advance.

NET Core** project and in one of my pages to edit a record the <input type="date"> is not showing me the value I'm passing it when I create the view in Razor.

This is my Razor code:

<div class="input-group">
    <div class="input-group-prepend">
        <i class="input-group-text fa fa-user"></i>
    </div>
    @Html.TextBoxFor(model => model.NewPriceList.PriceFrom, 
                     new { @class = "form-control", @type = "date", 
                           @Value = Model.NewPriceList.PriceFrom })
</div>

And this is what I can see in the Google Chrome developer tool thats been created as HTML

<input class="form-control" data-val="true" 
       data-val-required="The Obwiązuje od field is required." 
       name="NewPriceList.PriceFrom" type="date" 
       value="2/15/2019 12:00:00 AM">

But for some reason its not rendering correctly and this is what I get:

enter image description here

I have a project which I am handling the front-end with Angular and back-end with ASP.NET. While the back-end server was already working, I was making changes on Angular project and when I wanted to re-run the ASP.NET code, I got an unexpected error at the ASP.NET side even though I did not change anything on the server side. Here is the error;

Severity: Error 
Code: Build 
Description: Cannot find name: 'Map'    
Project: WebExperience.Test 
File: D:\Desktop\StyleLabs\node_modules\@types\selenium-webdriver\http.d.ts 
        .           

What can be causing this? Any help is appreciated, thanks.

I have nested grid-view. In Parent grid View when I Click to Expand the gridview the child gridview shows the related data. But when I click to Edit Child grid view The values go to textbox outside the gridview but not in dropdown list.

I have tried

 protected void gvSub_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView gvSub = sender as GridView;
    GridViewRow row = gvSub.Rows[e.NewEditIndex];

    Int32 a = Convert.ToInt32(gvSub.DataKeys[e.NewEditIndex][0]);
    TextBox1.Text = ((Label)row.FindControl("lblName")).Text;
    TextBox2.Text = ((Label)row.FindControl("lblPrice")).Text;
    TextBox3.Text = ((Label)row.FindControl("qty")).Text;

    String Cate = ((Label)gvSub.Parent.FindControl("lblCtName")).Text;
    DropDownList1.Items.FindByValue(Cate.ToString()).Selected = true;  

    btnSub.Text = "Update";
    e.Cancel = true;
}

Parent Gridview Value fetched in Cate but not getting in dropdownlist

I have a solution which has two projects: Class Library and MVC API .NET Core

On the class library I have a function that runs every 5 minutes and sets/updates a cache:

using Microsoft.Extensions.Caching.Memory;

public class PriceService : Interfaces.IPriceService
{

    private Timer _timer;
    private readonly IMemoryCache _cache;

    public PriceService(IMemoryCache cache)
    {
        _cache = cache;
    }


    public Task StartAsync(CancellationToken cancellationToken)
    {
        _timer = new Timer(GetMatchPrices, null, TimeSpan.Zero, TimeSpan.FromSeconds(300)); //every 5 minutes
        return Task.CompletedTask;
    }

    public Task StopAsync(CancellationToken cancellationToken)
    {
        _timer?.Change(Timeout.Infinite, 0);
        return Task.CompletedTask;
    }

    void GetMatchPrices(object state)
    {
        _cache.Set("Message", "Hello");

        var cacheget = _cache.Get("Message"); //gets the message



    }

}

How do I get this cache set in the Class Library in my MVC API controller?

I have a code block regards get a list like that in aspnetzero:

public async Task<List<DMNCCThueSuatDto>> GetDSThueSuat()
{
    using (_unitOfWorkManager.Current.SetTenantId(null))
    {
        var lstthueSuat = await _dmThueSuatRepository.Query(t => t.Where(i => 
        i.IsDeleted == false)).OrderBy("thuesuat_ma asc").ToListAsync();
        return ObjectMapper.Map<List<DMNCCThueSuatDto>>(lstthueSuat);
    }
}

i expected a list of DMNCCThueSuatDto is returned but the error "Cannot create a DbSet for 'DM_NCC_ThueSuat' because this type is not included in the model for the context." is always displayed.

I don't know why? Any helps is appreciated.

Thank you so much.

How to separate asp.net core mvc project into multiple assembly (.dll)?

I have 3 projects

  • MyApp Project
    • Controllers
      • HomeController.cs
    • Models
    • Views
      • Home
        • Index.cshtml
  • HR Project

    • Controllers
      • EmployeeController.cs
    • Models
      • EMPLOYEE.cs
    • Views
      • Employee
        • Index.cshtml
  • ACC Project

    • Controllers
      • ChartAccountController.cs
    • Models
      • ACCOUNT.cs
    • Views
      • ChartAccount
        • Index.cshtml

I want to compile into dll

  • HR Project
    • HR.dll
    • HR.Views.dll
  • ACC Project
    • ACC.dll
    • ACC.Views.dll

I want to add reference those dll (HR.dll, HR.Views.dll, ACC.dll, ACC.Views.dll) into MyApp Project.

And then run MyApp project can access Employee & Chart Account module too.

Not able to run the application.

Get Error:

The remote Debugger was unable to locate a resource dll (vsdebugeng.impl.resources.dll). please ensure that the complete remote debugger folder was copied or installed on the target computer.

Im getting data from a DB, where theres a datetime. I serialize the object to turn into a JSON but im getting the date like /Date(1486857600000)/. Is it possible to get only the date or even the timestamp directly ?

Serializing the query(object) from db to json var json = new JavaScriptSerializer().Serialize(query); return json;

calling the data like for (var key in jsonResult) { if (jsonResult.hasOwnProperty(key)) { (...) var getData = jsonResult[key].t_data; } }

Expected the date itself or timestamp but the output is /Date(1486857600000)/

I have a gridview for my aspx page. He needs : - OnRowDeleting button on each row - OnSorting (on headers) - OnRowEditing button on each row - OnRowCommand to add custom command (such as : duplicate and read) - OnPageIndexChanging to add pagination

Everything is working , my sorting command work, the pagination work, while I add the methods OnRowCommand="TableKO_RepartitionFonctions"".

When I add this lines (to add duplicate and read button), the OnSorting and OnPageIndexChanging not working. (OnRowDeleting and OnRowEditing steel fired).

I read on internet that it's because the OnRowCommand take the trigger at the place of OnSorting... But, I look in the debugger and nothing trigger anywhere.

Here is GridView code only, I suppose the problem come from this part of code and not from the c# because the c# is not even fired :

<asp:UpdatePanel ID="upnlGv" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:GridView 
            CssClass="gridTable table table-bordered table-hover footable"
            HeaderStyle-CssClass="thead-dark"
            GridLines="None"
            EmptyDataText="Aucune donnée"
            ShowHeaderWhenEmpty="true"   
            AutoGenerateColumns="False" 
            UseAccessibleHeader="true" 
            datakeynames="Numéro"
            ID="TableKO" 
            OnSorting="TableKO_SortCommand"  
            AllowSorting="true" 
            AllowPaging="true"
            PageSize="10"
            OnRowDeleting="TableKO_Deleting"
            OnRowEditing="TableKO_EditKO"
            OnRowCommand="TableKO_RepartitionFonctions"
            OnRowDataBound="TableKO_DataBound"
            OnPageIndexChanging="OnPageIndexChanging" 
            runat="server">
            <PagerSettings Mode="NumericFirstLast" Position="Bottom" PageButtonCount="7" />
            <PagerStyle CssClass="bs4-aspnet-pager" />
            <Columns>
                <asp:TemplateField  SortExpression="Numéro">
                    <HeaderTemplate>
                        <asp:LinkButton ID="headerNum" runat="server" Text="ID" ></asp:LinkButton>
                        <br />
                        <asp:TextBox  Visible="false" runat="server" ID="filterNum" AutoPostBack="true" ></asp:TextBox>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%#Eval("Numéro") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField SortExpression="Application">
                    <HeaderTemplate>
                        <asp:LinkButton ID="headerApp" runat="server" Text="Application ↕️" CommandArgument="Application" CommandName="Sort" ></asp:LinkButton>
                        <br />
                        <asp:DropDownList  AppendDataBoundItems="true" onselectedindexchanged="ddlApp_SelectedIndexChanged"  CssClass='custom-select' runat="server"  ID="DDListApp" AutoPostBack="true">
                            <asp:ListItem Value="0" Text="-- Applications --"></asp:ListItem>
                        </asp:DropDownList>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%#Eval("Application") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField SortExpression="[code erreur]">
                    <HeaderTemplate>
                        <asp:LinkButton ID="headerCode" runat="server" Text="Code d'erreur ↕️" CommandArgument="[code erreur]" CommandName="Sort" ></asp:LinkButton>
                        <br />
                        <asp:DropDownList AppendDataBoundItems="true" onselectedindexchanged="ddlCode_SelectedIndexChanged"  CssClass='custom-select' runat="server"  ID="DDListCode" AutoPostBack="true">
                            <asp:ListItem Value="0" Text="-- Codes erreur --"></asp:ListItem>
                        </asp:DropDownList>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%#Eval("code erreur") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField SortExpression="[type d'offre]">
                    <HeaderTemplate>
                        <asp:LinkButton ID="headerOffre" runat="server" Text="Offre ↕️" CommandArgument="[type d'offre]" CommandName="Sort" ></asp:LinkButton>
                        <br />
                        <asp:DropDownList AppendDataBoundItems="true" onselectedindexchanged="ddlOffre_SelectedIndexChanged"  CssClass='custom-select' runat="server"  ID="DDListOffre" AutoPostBack="true">
                            <asp:ListItem Value="0" Text="-- Types d'Offres --"></asp:ListItem>
                        </asp:DropDownList>
                        <br />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%#Eval("type d'offre") %>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Consulter">
                    <ItemTemplate>
                        <asp:Button ID="GoButton"  runat="server" Text="Consulter" CssClass="btn btn-sm btn-primary btn-block" UseSubmitBehavior="false" CommandName="Consulter"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Éditer">
                    <ItemTemplate>
                        <asp:Button D="EditButton"  runat="server" Text="Éditer" CssClass="btn btn-sm btn-secondary btn-block" UseSubmitBehavior="false" CommandName="Edit"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Duppliquer">
                    <ItemTemplate>
                        <asp:Button ID="CopyButton"  runat="server" Text="Duppliquer" CssClass="btn btn-sm btn-success btn-block" UseSubmitBehavior="false" CommandName="Duppliquer"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Supprimer">
                    <ItemTemplate>
                        <asp:Button UseSubmitBehavior="false" ID="deleteButton"  runat="server" Text="Supprimer" CssClass="btn btn-sm btn-danger btn-block" CommandName="Delete"/>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <div class="d-flex justify-content-between">
            <div>
                <a href="AdminKO.aspx?id=-1&copy=0" class=""> ← Retour vers la page de création de KO   </a> 
            </div>
        </div>  
    </ContentTemplate>
</asp:UpdatePanel>

Trying to achieve MTLSAuthentication using AuthenticationHandler class, have added AddAuthentication to services in ConfigureServices class and has created an Extension to register Scheme for Authentication and using the Authentication Scheme on the controllers and hasn't used any middleware , I would like to know how the call to HandleAuthenticateasync is called without any middleware code.

I have a very simple login form, but somehow, when the user presses Login the page flickers, but it simply does not hit the controller breakpoints for some reason.

               <form action="@Url.Action("Login", "Verify")" method="post">
                    <fieldset class="clearfix">
                        <p><span style="float:none;color:black; font-size:20pt;"></span></p>
                        <p><span style="float:none;color:black; font-size:20pt;"></span></p>
                        <p><span class="fa fa-user"></span>@Html.TextBoxFor(m => m.UserName, new { @class = "form-control", id="username", placeholder = "Username",  autofocus = "" })</p> <!-- JS because of IE support; better: placeholder="Username" -->
                        <p>
                            <span class="fa fa-lock"></span>@Html.PasswordFor(m => m.Password, new { @class = "form-control", id="password", placeholder = "Password" })
                        </p>
                        <div>
                            <span style="width:50%; text-align:right;  display: inline-block;"><input type="submit" value="Sign In"></span>
                        </div>
                    </fieldset>
                    <div class="clearfix"></div>
                </form>

And Inside my login controller I have a simple ActionResult named Verify with the 2 params.

   [HttpPost]
    public ActionResult Verify(string username, string password)
    {
       ...
    }

What exactly am I doing wrong here? It's not like this is rocket science.

I have created an excel spreadsheet using epplus library.

In this spreadsheet there are few columns with drop downs.

I need to make these drop downs searchable. We can make a drop down applied on a single cell, searchable using excel functions.

But it is not possible to apply the same on all the cells within a column.

But this is achievable using excel add-ins like 'excel campus-the-list-search-add-in' (https://members.excelcampus.com/products/the-list-search-add-in/categories/142180/posts/422610).

I don't want each and every user to install the excel add-in when they are using the spreadsheet created from my application.

I want the add-in to be automatically added, when creating the spreadsheet from my .NET application using epplus library.