Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I work on razor asp.net . I face issue I can't get value of blackprintername on bootstrap model

although I get the values of this property on page model but on razor html not display on input text box Black server Ip or black printer name .

I execute method type function OnGetCheckColors to get black server IP and black printer name but this not happen so why this happen and how to solve this issue

What I have tried:

$('#editbootstarp tbody').on('click', 'tr', function () {
                // Get the data from the clicked row
                var rowData = $(this).children('td').map(function () {
                    return $(this).text();
                }).get();

                // Set the values of the modal's input fields
             
                $('#editshelflabelModal #edit-id').val(rowData[0]);
              
                $('#editshelflabelModal #edit-Location').val(rowData[6]);
         
                // Show the modal
                $.ajax({
                    url: '?handler=CheckColors',
                    type: "GET",
                    data: { LocationName: rowData[6]},
                    success: function (result) {
                        $('#editshelflabelModal').modal('show');
                        console.log(result);
                    },
                    error: function (xhr, status, error) {
                        console.log(error);
                    }
                });
                $('#editshelflabelModal').modal('show');
            });

   public ActionResult OnGetCheckColors(string LocationName)
    {
    
                    List<SubPrinters> subPrintlist = _IAdcSupportService.GetAvailablePrintersLists(HttpContext.Session.GetString("BranchCodesSelected"), LocationName, "SUB");
                    if (subPrintlist != null && subPrintlist.Count > 0)
                    {
                        foreach (SubPrinters subPrint in subPrintlist)
                        {
                            if (subPrint.Category == "Red" && subPrint.IsActive)
                            {
                                Redprintername = subPrint.PrinterName;
                                Redserverip = subPrint.PrinterIP;
                          
                            }
                            
                            else if (subPrint.Category == "Black" && subPrint.IsActive)
                            {
                                Blackprintername = subPrint.PrinterName;
                                Blackserverip = subPrint.PrinterIP;

                            }
                        }
                    }
           
        return new JsonResult("success");
    }

<div class="modal fade" id="editshelflabelModal" tabindex="-1" role="dialog" aria-labelledby="userDetailsModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <h5 class="modal-title" style="text-align:center;">
               

            </h5>
            <div class="modal-header">
                <h5 class="modal-title" id="editshelflabelModaldata" style="margin-left:200px;">Hi,@TempData["UserID"]</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true"</span>
                </button>
            </div>
            <form id="edit-form" method="post" asp-page-handler="shiftDataUp">
            <div class="modal-body">
        
                    <input type="hidden" id="edit-id" name="ShiftId">
                    <div class="form-group">
                        <label for="edit-server">Server IP</label>
                        <input type="text" class="form-control" id="edit-ip" name="serverip">
                    </div>
                    <div class="form-group">
                        <label for="edit-printer">Printer Name</label>
                        <input type="text" class="form-control" id="edit-printername" name="printername">
                    </div>
                    <div class="form-group">
                        <label for="edit-locationsdata">Location Name</label>
                        <input type="text" class="form-control" id="edit-Location"  name="Location">
                    </div>
                    
              
          
                    <div class="row">
                        

                        
                  

                    
                    
                    <div id="Blackdiv">
                        <div class="row">
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <h6 class="heading text-darker ml-9" style="margin-top: 12%;">Black Printer</h6>
                                </div>
                            </div>
                            <div class="col-lg-4">
                                <div class="form-group">
                                    <label class="form-control-label" for="txtBlackIP">IP Address</label>
                                    <input type="text" id="txtblackip-id" asp-for="Blackserverip" name="blackipdata">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-control-label" for="txtBlackName">Printer Shared Name</label>
                                    <input type="text"  id="txtBlackName" value="@Model.Blackprintername" class="form-control">
                                    
                                </div>
                            </div>
                        </div>
                    </div>
                

          

            </div>
               
           
            </form>
        </div>
        
    </div>
    
</div>
Posted
Updated 2-Jul-23 15:11pm
Comments
Graeme_Grant 2-Jul-23 21:09pm    
[moved]

1 solution

Have you tried setting a breakpoint and stepping through your code, checking variable values to see what is happening?

If you are unsure how, please watch this video: Debug JavaScript - Chrome Developers[^]
 
Share this answer
 

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