DaClownie
✅ OnParametersSetAsync() in a blazor component being called before clicking a button in Blazor app
I created a component in Blazor, a
CourseList
which has a Parameter of TermId
its added to the Terms.razor
page as such
termId
is a Guid
that is only being assigned a value when one of the buttons next to the rendered terms is clicked.
The CourseList
component itself only displays if a bool showDetails
is set to true. However, when the page is loaded, it automatically displays the table headers and tries to load the list of Courses that are within that if (showDetails)
CourseList.razor:
Why is this OnParameterSetAsync()
being called on page load before clicking a button?4 replies
✅ How to access specific fields from an [ObservableProperty] ObservableCollection<Object>?
Hoping to pick someone's brain on MVVM and MAUI. So I have a ViewModel that looks like:
and I want to have the xaml create each of the objects in the ObservableCollection... But the items are of type Term, so how do I tell the xaml to access the
IdText
of the Term
object and print that?
I'm not sure how best to handle a "complex" object vs. just an ObservableCollection<string>
.
I essentially want the term.Name
to be displayed for each Term
object in the Collection, but when the term.Name
is tapped in my app, I want it to reference pass the term.Id
to an eventual call to open a CoursePage(term.Id)
227 replies
Handling exceptions when querying with EF
Looking for a little insight... so I'm just working through how to properly use EntityFramework, and I'm handling a simple login from a list of users from a database (yes I know the password should be hashed and salted, but i was going to handle that after. Just want it to work for now)
My
Users
database has Id
which is a BINARY(16)
for a smaller method of storing GUID, and it has a virtual column it can reference for IdText
which is the full version of the GUID in a string format. I'm passing the GUID string back to my application to use for future queries on courses or semesters in school bound to your user.
My login is
The documentation says that it will return the first result matching the query or throw back an ArgumentNullException
. How do I handle the exception? Or should I be using First? is there a better method similar to an Int32.TryParse
which returns the value or silences the exception? or do I create my own TryParse
method for my Users
model that throws away the exception because the only exception would be if the User
doesn't exist?
And would I want to mix that into this function of GetUserId
? or would I be better putting this inside the SubmitButton_OnClicked
method? Sorry, this is probably a lot of ramblings
I've never used Try in any of my prior programs so i'm reading on the best practices and looking at docs and I just don't want to develop bad habits.53 replies
NullReferenceException but checking for Null?
I click a button on my .NET MAUI UI to Create a new course. ContentPage loads, I enter my information. If I leave any of the entry fields blank, the program crashes... stating
System.NullReferenceException Message=Object reference not set to an instance of an object.
23 replies
New ContentPages in .net MAUI app don't have InitializeComponent() methods
I'm following a few guides to learn how to do Navigation in a .NET MAUI app which I need to apply for a project for school. All of the guides show creation of multiple ContentPages, assigning it as such in
App.xaml.cs
I created a new ContentPage in the solution named TermPage
but it doesn't have a InitializeComponent()
and I'm unable to Build my project and send it to the Android Emulator. How come the guides have no issue with the creation of the InitializeComponent()
method and mine does? And How do I fix it?17 replies