0

I am looking for some advice on the best way to disable two list items based on the account being locked and the value in the state column is equal to 1.

I have a model which generates a random number:

public int IsLocked
{
    get
    {
        var rnd = new Random();
        return rnd.Next(0, 2);
    }
}

This is my Partial View:

<td class="hidden-xs hidden-sm">
                @if (t.IsLocked == 1)
                {
                <span class="glyphicon glyphicon-lock locked"></span>
                }
                else
                {
                <span class="glyphicon glyphicon-ok"></span>
                }
            </td>
            <td class="updateTableRow text-center">
                <div class="dropdownContainer btn-group text-right">
                    <button id="@actionWorkId" type="button" class="btn btn-primary br2 btn-xs fs12 dropdown-toggle songmanagement-btn" data-toggle="dropdown" aria-expanded="false">
                        Action
                        <span class="caret ml5"></span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        <li>
                            <a href="@Url.Action("Recordings", "ArtistAccount", new
                                {
                                    accountcode = fullAccountCode,
                                    songcode = t.SongId
                                })" id="@recordingWorkId" data-container="body" data-rowhover="editTableRow" class="js_Recordings">Recordings</a>
                        </li>
                        <li>
                            <a href='@Url.Action("EditSong", "ArtistAccount", new
                                     {
                                         songcode = t.SongId,
                                         accountcode = fullAccountCode,
                                         page = Model.PagingInfo.Page,
                                         take = Model.PagingInfo.Take,
                                         sortBy = Model.PagingInfo.SortPropertyName,
                                         sortAsc = Model.PagingInfo.SortAscending
                                     })' id="@editWorkId" data-container="body" data-rowhover="editTableRow" class="js_EditSong">Edit</a>
                        </li>
                        <li>
                            <a href="#" id="@deleteWorkId" data-container="body" data-toggle="tooltip" title="Delete" data-rowhover="deleteTableRow" class="js_DeleteSong">Delete</a>
                        </li>
                        <li>
                            <a href="@Url.Action("TuneCodes", "ArtistAccount", new
                                    {
                                        accountCode = fullAccountCode,
                                        workCode = t.SongId,
                                    })" id="@tuneCodeId" data-container="body" data-toggle="tooltip" title="Tune Codes" data-rowhover="editTableRow">Tune Codes</a>
                        </li>
                    </ul>
                </div>
            </td>
        </tr>

Is there a way using C# and ASP.NET that I could acheieve this?

3
  • I'm not sure what you are asking here. Are you looking for a way to see if your edit and recording - links should be enabled or not based on t?
    – sander
    Commented May 17, 2018 at 12:37
  • then I think the way you are doing it is just fine!
    – sander
    Commented May 17, 2018 at 12:54
  • @sander that wont be dynamic though if I just add the disabled attribute to the html
    – Rob
    Commented May 17, 2018 at 13:08

1 Answer 1

0

Solved my issue using the following code:

<li>
                            @if (t.IsLocked == 1)
                            {
                            <a class="isDisabled" data-toggle="tooltip" title="You cannot edit this song until pending writer edits are approved">Recordings</a>
                            }
                            else
                            {

                        <a href="@Url.Action("Recordings", "ArtistAccount", new
                                {
                                    accountcode = fullAccountCode,
                                    songcode = t.SongId
                                })" id="@recordingWorkId" data-container="body" data-rowhover="editTableRow" class="js_Recordings">Recordings</a>
                            }</li>
                        <li>
                            @if (t.IsLocked == 1)
                            {
                            <a class="isDisabled" data-toggle="tooltip" title="You cannot edit this song until pending writer edits are approved">Edit</a>
                                }
                                else
                                {
                                <a href='@Url.Action("EditSong", "ArtistAccount", new
                                     {
                                         songcode = t.SongId,
                                         accountcode = fullAccountCode,
                                         page = Model.PagingInfo.Page,
                                         take = Model.PagingInfo.Take,
                                         sortBy = Model.PagingInfo.SortPropertyName,
                                         sortAsc = Model.PagingInfo.SortAscending
                                     })'
                                   id="@editWorkId" data-container="body" data-rowhover="editTableRow" class="disabled">Edit</a>
                                }

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.