razor

Blazor component needs to modify value of parent component

本小妞迷上赌 提交于 2021-02-11 15:41:07
问题 I have these two components in my Blazor app: Component1.razor: <CascadingValue Value=this> <Component2/> </CascadingValue> <p>@DisplayedText</p> @code { public string DisplayedText = string.Empty; } Component2.razor: <button @onclick=@(e => { C1.DisplayedText = "testing"; })>Set DisplayedText</button> @code { [CascadingParameter] public Component1 C1 { get; set; } } When I click the "Set DisplayedText" button, the text in the p element in Component1 should change to testing , but it does not

How to redirect .ASPX pages to .NET Core Razor page

ぃ、小莉子 提交于 2021-02-11 14:57:32
问题 We are moving a big asp.net web site to .NET Core Razor pages site. All over the internet there are links that point to our site and we want those links to work after our migration. We will kept the same url format, but without the extension .aspx. Summary, we want our old url: example.com/item.aspx be handle by .net core razor page, as example.com/item 回答1: You could use the URL Rewriting Middleware to remove the ".aspx" extensions. Check the following code: Use AddRedirect to create a rule

Asp.net mvc compiler error when trying to invoke View Component from view page

让人想犯罪 __ 提交于 2021-02-11 12:03:17
问题 I am trying to create my first View Component in my MVC project but have come to a halt. When I try to invoke my View Component from the razor view page I get an error that states: "The name 'await' does not exist in the current context". Code I use to call the View Component: @await Component.InvokeAsync("Example") View Component class: namespace MyWebApp.ViewComponents { public class ExampleViewComponent : ViewComponent { public IViewComponentResult Invoke() { var user = Account.GetCurrent(

How to generate dynamically blazor's @bind-Value?

北战南征 提交于 2021-02-11 08:07:33
问题 I'm playing with Blazor and I'd like to create a dynamically generated form, which is part of a grid. The entity type of the data is passed to the grid and this is the base of the form. The problem I'm facing now is @bind-Value , which is needed to be able to edit the given entity. I use BlazorStrap, and it is a Blazor Server Side project. I have the following code in the razor file: @{ string bind = $"{nameof(_editedItem)}.{propertyInfo.Name}"; } <BSBasicInput InputType="InputType.Text" id="

How to generate dynamically blazor's @bind-Value?

柔情痞子 提交于 2021-02-11 08:05:36
问题 I'm playing with Blazor and I'd like to create a dynamically generated form, which is part of a grid. The entity type of the data is passed to the grid and this is the base of the form. The problem I'm facing now is @bind-Value , which is needed to be able to edit the given entity. I use BlazorStrap, and it is a Blazor Server Side project. I have the following code in the razor file: @{ string bind = $"{nameof(_editedItem)}.{propertyInfo.Name}"; } <BSBasicInput InputType="InputType.Text" id="

Asp.net Core Applications Issue with Razor and MVC Pages

不羁岁月 提交于 2021-02-10 23:38:07
问题 I have reinstalled my VS 2019 and cloned my applications on my machine. But suddenly all the applications stopped showing add -> Controller --> MVC 5 Controller and its View. After rebuild my application is converted into Razor from MVC Core 3.1. and now all applications throws error of g.cshtml.cs file. Help me to fix this issues. Why my .net core MVC application is converted to Razor. Why application not adding MVC controller and view. 回答1: Create an empty ASP.NET Core MVC project Change

Asp.net Core Applications Issue with Razor and MVC Pages

瘦欲@ 提交于 2021-02-10 23:36:32
问题 I have reinstalled my VS 2019 and cloned my applications on my machine. But suddenly all the applications stopped showing add -> Controller --> MVC 5 Controller and its View. After rebuild my application is converted into Razor from MVC Core 3.1. and now all applications throws error of g.cshtml.cs file. Help me to fix this issues. Why my .net core MVC application is converted to Razor. Why application not adding MVC controller and view. 回答1: Create an empty ASP.NET Core MVC project Change

File upload in ASP.NET Core 2 razor pages

强颜欢笑 提交于 2021-02-10 20:44:51
问题 I'm trying to do a simple file upload in asp.net core 2 razor pages. I have the code below. Please realize that it is imcomplete. When i run in my VS2017, I check my FileUpload object, and it is unfortunately null. I would hope that it is something besides null and I could create a stream to get some data out of it. However, with the object being null, I would suspect that I do not have something tied together correctly. Any thoughts are appreciated. Thanks. Code behind cs: public class

File upload in ASP.NET Core 2 razor pages

跟風遠走 提交于 2021-02-10 20:43:27
问题 I'm trying to do a simple file upload in asp.net core 2 razor pages. I have the code below. Please realize that it is imcomplete. When i run in my VS2017, I check my FileUpload object, and it is unfortunately null. I would hope that it is something besides null and I could create a stream to get some data out of it. However, with the object being null, I would suspect that I do not have something tied together correctly. Any thoughts are appreciated. Thanks. Code behind cs: public class

Is there a way to get Google Sheets to default to a different tab each day?

半世苍凉 提交于 2021-02-10 17:26:46
问题 I have an MVC application that links to a Google Sheet doc via siteloader. It's loading great but defaulting to load the first tab in the sheets - working as designed obviously. Here's what I need to do: The tabs in this sheet are separated by date. So, for example, today's 8/22/20. The tab displays "SAT 082220." Tomorrow's tab will be "SUN 082320" and so on. I need siteloader to default to today's tab when the project loads. So basically it just needs to load the next tab in the list each