Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I work on razor asp.net core .i face issue selectedbranchid is inside post form form is get selected value without any issue

but if i use another post and get selectedbranchid it become null why

so How to solve issue please

on page model

why bind property outside form become null and how to solve this issue

What I have tried:

[BindProperty]
        public string SelectedBranchId { get; set; }

<div id="ShelfLabelPrintrSetupAdcSupport" style="margin-top:20px;">
        <form id="FrmShelfLabelPrintrSetup" method="post" onsubmit="return validateForm() ">

            <div class="row">
                <div class="col-lg-12 col-12 row">
                    <div class="col-md-3 col-lg-2">
                        <label for="branch-selectlbl" style="margin-left:3px;font-size:15px;font-family: 'Open Sans', sans-serif;font-weight: bold;">Print Server</label>
                  
                        <select id="branch-select" asp-for="SelectedBranchId" name="selectbranchid" class="form-select" style="margin-left:3px;font-size:15px;font-family: 'Open Sans' , sans-serif;font-weight: bold;" onchange="toggleButtonVisibility()">
                            <option value="0">--Select--</option>
                            @foreach (var branches in Model.branches)
                            {

                                <option value="@branches.iBranchCode">@branches.vBranchDesc</option>


                            }
                        </select>
                       
                    </div>
                    <input type="hidden" id="SelectedText" name="SelectedText" asp-for="SelectedBranchId" value="SelectedBranchId" />
                    <div class="col-md-3 col-lg-2">
                        <br>
                        <button  id="Searchtxt" type="submit" name="searchButton" value="search" asp-page-handler="Search" style="width:100px;margin-top:7px;" class="btn btn-primary">Search</button>
                        

                    </div>

                    
                </div>
            </div>







        </form>

    </div>
</div>

<button id="createTxt" data-toggle="modal" data-target="#CreateshelflabelModal" style="width:100px;margin-top:7px;margin-left:7px;display:none;" class="btn btn-primary">Create</button>
 
now i will check another post method not related to form or another form different with post


Copy
public ActionResult OnPostCreateUsers(string selectbranchid)
        {

string selectedbranchid=SelectedBranchId;  here when check it become null

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900