How to capture the parameter values ​of a component in new variables

I have this component with some parameters that take a value within the same component. What I want is to call the component from another place and there obtain the value of those parameters (not change or assign them, but capture them in new variables) to perform some validations with those values. This is so that a component is initialized by validating in the local storage if there is any key UserMail and if so it captures the value and the idea is to validate and use the component on other pages where at the beginning it is checked if the component contains value in userCorreo and if so, render the pages with that layout My component with parameters:

@inject NavigationManager NavigationManager
@inject Blazored.LocalStorage.ILocalStorageService _InjectILocalStorage

@rendermode InteractiveServer
<p>@_UserCorreo</p>
@code {

    public string _UserCorreo { get; set; } = "A";

    public bool _ValidateUserCorre { get; set; } = false;
 
    
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {

        if (firstRender)
        {

            _UserCorreo = await _InjectILocalStorage.GetItemAsync<string>("UserCorreo");

            if (string.IsNullOrEmpty(_UserCorreo))
            {
                NavigationManager.NavigateTo("/Login", forceLoad: true);
            }
            else
            {
                
                StateHasChanged();

            }
        }


    }
}

Where I want to call it (in the mainLayout):

@inherits LayoutComponentBase

<!-- Usando la referencia del componente UserName -->
<UserName @ref="Us" />

<!-- Accediendo a las propiedades públicas del componente UserName -->
<p>@Us._UserCorreo</p>

@if (Us._ValidateUserCorre)
{
    <div class="page">
        <div class="sidebar bg-1">
            <NavMenu />
        </div>

        <main>
            <div class="top-row px-4 bg-2">
                <span class="mx-3 text-secondary">Hi, @Us._UserCorreo</span>
                <div class="contenedor-img-perfil bg-light"></div>
            </div>

            <article class="content px-4">
                @Body
            </article>
        </main>
    </div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">????</a>
    </div>
}

@code {
    // Declaración del componente UserName
    private UserName Us;

    // Método OnInitialized para inicializar el componente
    protected override void OnInitialized()
    {
        // Inicialización del componente UserName
        
    }
}

What I want is to do this way, have a component that calls the new pages and this has the information of whether there is an email in the local storage with a specific key, if there is, render the page or if not, redirect from the component to login…what I need is from a component to extract the values ​​of the component that already detects whether the email exists or not and even redirects to login if it does not, and if it exists, it assigns it to a variable.. I’m Open to new methods, if possible simple, quality and consistent methodologies.

New contributor

Ferdy Andrés is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật