blazor-server-side

Blazor link - disable href if there's an onclick method

 ̄綄美尐妖づ 提交于 2020-04-12 16:57:25
问题 In Blazor I have an <a> element that has both a href and an onclick method: <a href="" onclick="@(() => ChangePage(_someObject))">Test</a> onclick calls this method: private bool ChangePage(object objectToDisplay) { _currentObject = objectToDisplay; StateHasChanged(); return false; } Normally in JavaScript returning false from the event method stops the subsequent navigation to the link in the href but this doesn't seem to be working with my code above. How can I stop Blazor changing the page

Maintaining SynchronizationContext for nested (not first or last) methods in Blazor

痞子三分冷 提交于 2020-04-11 18:21:40
问题 Using the default project that loads with Visual Studio 2019 when you create a new blazor server-side project in .NetCore 3.1, consider the following example (a slight change to their own counter example page): <button class="btn btn-primary" @onclick="SingleMethodUpdate">Click Me</button> <label>Update from same method: @result</label> <button class="btn btn-primary" @onclick="NestedMethodUpdate">Click Me</button> <label>Update from nested method: @nestedResult</label> And the code-behind to

How to place submit button for a Blazor EditForm outside of the component

坚强是说给别人听的谎言 提交于 2020-04-10 06:33:11
问题 The Blazor documentation's Form Validation example has a submit button component within the EditForm component: <EditForm Model="@starship" OnValidSubmit="@HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <p> <label for="identifier">Identifier: </label> <InputText id="identifier" bind-Value="@starship.Identifier" /> </p> Snip.... <button type="submit">Submit</button> Snip... </EditForm> Is there anyway to place that submit button outside of the EditForm tags and still

How to place submit button for a Blazor EditForm outside of the component

烈酒焚心 提交于 2020-04-10 06:32:07
问题 The Blazor documentation's Form Validation example has a submit button component within the EditForm component: <EditForm Model="@starship" OnValidSubmit="@HandleValidSubmit"> <DataAnnotationsValidator /> <ValidationSummary /> <p> <label for="identifier">Identifier: </label> <InputText id="identifier" bind-Value="@starship.Identifier" /> </p> Snip.... <button type="submit">Submit</button> Snip... </EditForm> Is there anyway to place that submit button outside of the EditForm tags and still

Blazor Before Render Call Function

泪湿孤枕 提交于 2020-03-28 06:55:11
问题 I am running an Blazor Server-Side client, which contacts an api gets a token and saves it in local storage. When i route to a second page i want to check if token is there so !null. I can't find the right place to check this or where. I tried on a layout and with overriding OnInitialized and it works but you get this horrid flicker where the ui is loaded and then the check is finished so it redirects, basically the user partially sees the page they shouldnt have access too. Where should i be

Blazor Grid with master-detail

﹥>﹥吖頭↗ 提交于 2020-03-26 07:25:19
问题 I am doing some project for college in Blazor(.net wasm) and have some page that should implement master-detail view of students. For table look and pagination I used BlazorGrid and it was great but now am stuck because i cannot insert new row in table when name of student is clicked. Does anyone have idea how to do this or some other way of doing pagination in Blazor. Link on BlazorGrid git https://github.com/AnkitSharma-007/BlazorGrid and this is pic of my screen, after clicked on name i

How to format the date using local culture using the blazor <InputDate /> tag

橙三吉。 提交于 2020-03-23 12:38:09
问题 I am using the tag in my Blazor app. But how can i format the date using my own culture ? <InputDate class="form-control" @bind-Value="@ValidDate" @bind-Value:culture="nl-BE" @bind-Value:format="dd/MM/yyyy" /> regards Dieter 回答1: The answer is @bind-Value:format , like so @page "/" <EditForm Model="@CurrentPerson"> <InputDate @bind-Value="@CurrentPerson.DateOfBirth" @bind-Value:format="dd/MM/yyyy"/> </EditForm> @code { Person CurrentPerson = new Person(); public class Person { public DateTime

Change class for selected div only

好久不见. 提交于 2020-03-05 04:36:57
问题 I would like it to only change the class for the clicked div . Currently it will change the class for all div s. I have written this as a Blazor component. @for (int i = 0; i < 5; i++) { <div class="@divClass" @onclick="_ => ChangeDivClass()">@i</div> } @code { String divClass; private void ChangeDivClass() { if (divClass == "red") { divClass = String.Empty; } else { divClass = "red"; } } } 回答1: You can use an array instead of one variable. @for (int i = 0; i < divClass.Length; i++) { var

How to disable/hide a button as soon as clicked in Blazor?

生来就可爱ヽ(ⅴ<●) 提交于 2020-03-03 10:30:02
问题 We are noticing that in our Blazor server-side application, users are able to click a button more than once unintentionally. How can I prevent this using options available in Blazor framework? Anything as simple as changing the text of the button to "processing..." as soon as they click the button will suffice our requirements but I am not sure how to achieve this. Handler for click event takes few seconds to process. Any pointers? 回答1: You likely have one of two problems or both: Latency is

How to disable/hide a button as soon as clicked in Blazor?

◇◆丶佛笑我妖孽 提交于 2020-03-03 10:28:10
问题 We are noticing that in our Blazor server-side application, users are able to click a button more than once unintentionally. How can I prevent this using options available in Blazor framework? Anything as simple as changing the text of the button to "processing..." as soon as they click the button will suffice our requirements but I am not sure how to achieve this. Handler for click event takes few seconds to process. Any pointers? 回答1: You likely have one of two problems or both: Latency is