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?
@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 < 0 || newOperation.OrderInWhichToPerform > 10)
{
showValidationErrors = true;
return;
}
if(newOperation.ImageData == null || newOperation.ImageData.Length == 0)
{
showValidationErrors = true;
return;
}
if (newOperation.Device == null || newOperation.Device.DeviceID <= 0)
{
showValidationErrors = true;
return;
}
// only proceed when fields are valid.
int newOperationId = operations.Count + 1;
newOperation.OperationID = newOperationId;
operations.Add(newOperation);
newOperation = new Operation();
}
// method invokes for device selection.
void OnDeviceSelected(ChangeEventArgs e)
{
int deviceId = Convert.ToInt32(e.Value);
newOperation.Device = devices.FirstOrDefault(d => d.DeviceID == deviceId);
}
void ShowAddOperationModal()
{
showAddOperationModal = true;
Console.WriteLine("Modal opened");
}
}
@if(showAddOperationModal)
{
}
Satyaprakash SamantarayPosted Nov 21, 2023, 6:19 PM
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