Hi Team
I am debugging a message to the console to check if i am receiving a response from the client side. When clicking the button, i want to click the button then it opens modal form. Any ideas how can i fix this issue?
C#
@using Models;
@code {
Operation newOperation = new Operation();
List operations = new List();
List devices = new List();
bool showValidationErrors = false;
bool showAddOperationModal = false;
protected override void OnInitialized()
{
devices = new List
{
new Device {DeviceID = 1, Name = "Barcode Scanner"},
new Device {DeviceID = 2, Name = "Printer"},
new Device {DeviceID = 3, Name = "Camera"},
new Device {DeviceID = 4, Name= "SocketTray"}
};
}
void AddOperation()
{
showValidationErrors = false;
// validate fields
if(string.IsNullOrWhiteSpace(newOperation.Name))
{
showValidationErrors = true;
return;
}
if(newOperation.OrderInWhichToPerform 10)
{
showValidationErrors = true;
return;
}
if(newOperation.ImageData == null || newOperation.ImageData.Length == 0)
{
showValidationErrors = true;
return;
}
if (newOperation.Device == null || newOperation.Device.DeviceID d.DeviceID == deviceId);
}
void ShowAddOperationModal()
{
showAddOperationModal = true;
Console.WriteLine("Modal opened");
}
}
Add New Operation
@if(showAddOperationModal)
{
Add New Operation
×
Operation Name
@if (showValidationErrors && string.IsNullOrWhiteSpace(newOperation.Name))
{
Operation is required
}
Order In Which to Perform
@if (showValidationErrors && (newOperation.OrderInWhichToPerform 10))
{
Order must be between 1 and 10
}
Image Data
@if (showValidationErrors && (newOperation.ImageData == null || newOperation.ImageData.Length == 0))
{
Image data is required
}
Select Device
Select device Types
@foreach (var device in devices)
{
@device.Name
}
@if (showValidationErrors && (newOperation.Device == null || newOperation.Device.DeviceID Please select a device
}
}
Satyaprakash SamantarayRank #101 · 21.1K reputationPosted Nov 21, 2023, 1:19 PM EST
That happens because of missing or invalid path or any js and css reference.
Please check my blog link. That might be helpful as reference and u can change in your code as per requirement
https://www.c-sharpcorner.com/blogs/bootstrap-modal-popup-using-asp-net-mvc