1

I'm trying to create a function that takes in a string that corresponds to an item within an enum. The following syntax works fine but I want to be able to change the ChannelType.EndUser to use the parameter passed into the function instead, is this possible? Here is my function:

  function closeEdit(channel){
             @{

                  var channels = Enum.GetValues(typeof(ChannelType))
                    .Cast<ChannelType>()
                    .Except(new ChannelType[] {ChannelType.EndUser});

                  }
                  @foreach (ChannelType channeltype in channels)
        {
        @:var buttonname = "#Cancel_" + '@(channeltype.ToString())' + "_Update";
        @:if(buttonname != 'Cancel_EndUser_Update'){

        @:$(buttonname).click();}
        }
     }
4

1 に答える 1

0

Except実際の C# コードではそれを行うことはできません。その を削除してから、 が渡されたアイテムでないforeachことを確認する必要があります。ChannelType

このようなもの:

 function closeEdit(channel){
     @{
         var channels = Enum.GetValues(typeof(ChannelType))
             .Cast<ChannelType>()
      }
      @foreach (ChannelType channeltype in channels)
      {
          @:var buttonname = "#Cancel_" + '@(channeltype.ToString())' + "_Update";
          @:if(buttonname != 'Cancel_EndUser_Update' && '@(channelType.ToString())' != channel){

          @:$(buttonname).click();}
      }
 }
于 2013-03-21T10:19:04.067 に答える