Я не могу обновить свои кнопки в проекте ASP.NET MVC.C#

Место общения программистов C#
Ответить
Anonymous
 Я не могу обновить свои кнопки в проекте ASP.NET MVC.

Сообщение Anonymous »

Например, вот скриншот со страницы просмотра файла, чтобы объяснить мою проблему:
введите здесь описание изображения
Когда я нажимаю вторую кнопку 15 раз , первая кнопка становится красной вместо второй. Я хочу сделать красной кнопку, которую я нажал 15 раз.
Я много раз пытался решить проблему с помощьюchatgpt, но это не сработало. В каждом случае gpt пытается решить проблему, ничего особенного. Я объяснил проблему и попробовал разбить ее на части, затем присвоить идентификаторы кнопкам и обработать их с помощью этих идентификаторов, но это снова не сработало.
ogretmendatalari.cs (модель):
namespace randevu.Models
{
public class ogretmendatalari
{
public int Id { get; set; }
public string? kullanici_adi { get; set; }
public string? sifre { get; set; }
public string? sinif { get; set; }
public string? tcno { get; set; }
public string? email { get; set; }

public string? ders { get; set; }
public string? musait_gunler { get; set; }
public string? musait_saat_araligi { get; set; }
public string? randevu_click_sayisi { get; set; }
}
}

ogretmenlerlistesi.cshtml (просмотр):
@model IEnumerable
@{
ViewData["title"] = "Öğretmen Listesi";
}
@{
var elemanlar = ViewBag.Elemanlar as string[];

}







Model Listesi



body {
overflow-x: hidden;
background: linear-gradient(135deg, #2b2b2b, #1d1d1d);
position: relative;
font-family: 'Arial', sans-serif;
}

.background-shape {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.1);
}

.shape-1 {
width: 300px;
height: 300px;
top: -150px;
left: -150px;
background: rgba(255, 255, 255, 0.2);
}

.shape-2 {
width: 200px;
height: 200px;
bottom: 50px;
right: 50px;
background: rgba(255, 255, 255, 0.15);
}

#sidebar {
position: fixed;
top: 0;
left: -250px;
width: 250px;
background-color: #343a40;
color: white;
height: 100vh;
padding: 15px;
transition: left 0.4s ease;
display: flex;
flex-direction: column;
justify-content: space-between;
}

#sidebar.active {
left: 0;
}

#sidebar a {
color: white;
text-decoration: none;
margin-bottom: 10px;
display: block;
padding: 10px;
border-radius: 5px;
background-color: #495057;
}

#sidebar a:hover {
background-color: #6c757d;
}

#content {
padding: 20px;
margin-left: 0;
transition: margin-left 0.4s ease;
}

#content.shifted {
margin-left: 250px;
}

#toggle-btn {
position: fixed;
top: 50%;
left: 0;
transform: translateY(-50%);
background-color: #007bff;
color: white;
border: none;
padding: 10px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
cursor: pointer;
z-index: 1000;
transition: left 0.4s ease;
}

#toggle-btn.shifted {
left: 250px;
}

.exit-btn {
background-color: red !important;
display: flex;
align-items: center;
padding: 10px;
border-radius: 5px;
text-decoration: none;
color: white !important;
}

.exit-btn:hover {
background-color: darkred !important;
}

.home-btn {
background-color: #28a745;
color: white;
padding: 10px 20px;
border-radius: 5px;
text-decoration: none;
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
}

.home-btn:hover {
background-color: #218838;
}

.table-container {
margin-top: 50px;
background: linear-gradient(135deg, #17a2b8, #6f42c1);
border-radius: 15px;
padding: 25px;
color: white;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
font-family: 'Arial', sans-serif;
}

table th,
table td {
padding: 15px;
text-align: left;
font-size: 16px;
font-weight: bold;
}

table th {
background-color: #495057;
color: white;
}

table tr:nth-child(even) {
background-color: #f1f1f1;
}

table tr:nth-child(odd) {
background-color: #e0e0e0;
}

table td {
color: #333333;
}

.centered-btn {
display: flex;
justify-content: center;
margin-top: 20px;
}

/* Flexbox düzeni ve buton simetrisi */
.modal-body {
display: flex;
flex-wrap: wrap;
gap: 10px;
}

.modal-body button {
width: 100%;
height: 50px; /* Sabit yükseklik */
display: inline-block;
text-align: center;
}

.modal-body button p {
margin: 0;
line-height: 50px; /* Yüksekliği dengelemek için */
}

button.alert-danger {
background-color: red;
color: white;
}










Hoşgeldin, @TempData["kullaniciadi"] !
Öğretmenler/ Öğretmenden Randevu Al



🚪
Çıkış Yap







Öğretmenlerin Müsait Randevu Listesi



Öğretmen Adı
Email
Dersi
Randevu



@foreach (var item in Model)
{

@item.kullanici_adi
@item.email
@item.ders

Randevu Al








@item.kullanici_adi için Randevu Al



@if (!string.IsNullOrEmpty(item.musait_saat_araligi))
{
string randevualanogrenci = TempData["kullaniciadi"].ToString();
string randevusualinanogretmen = item.kullanici_adi;

var saatler = item.musait_saat_araligi.Split(';');
var clickCounts = !string.IsNullOrEmpty(item.randevu_click_sayisi) && item.randevu_click_sayisi.Split(';').Length == saatler.Length
? item.randevu_click_sayisi.Split(';').Select(int.Parse).ToList()
: new List(new int[saatler.Length]);

for (var i = 0; i < saatler.Length; i++)
{
var saat = saatler;
var clickCount = clickCounts;

if (clickCount >= 15)
{

@saat

BU RANDEVU DOLU!
}
else
{

@saat



Randevu Alan Öğrenciler: @clickCount
}
}
}
else
{
Müsait saat bilgisi bulunamadı.
}


Kapat




}






Geri Dön











Çıkış Yap


Çıkış yapmak istediğinizden emin misiniz?

Hayır
Evet








const sidebar = document.getElementById('sidebar');
const content = document.getElementById('content');
const toggleBtn = document.getElementById('toggle-btn');

toggleBtn.addEventListener('click', () => {
sidebar.classList.toggle('active');
content.classList.toggle('shifted');
toggleBtn.classList.toggle('shifted');
});

const confirmLogout = document.getElementById('confirm-logout');
confirmLogout.addEventListener('click', () => {
window.location.href = '/AnaSayfa';
});





Подробнее здесь: https://stackoverflow.com/questions/790 ... vc-project
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»