PreferredControlType

HtmlLoadOptions.PreferredControlType property

İçe aktarılan <giriş> ve <seçim> öğelerini temsil edecek tercih edilen belge düğümü türünü alır veya ayarlar. Varsayılan değer:FormField .

public HtmlControlType PreferredControlType { get; set; }

Notlar

Lütfen bu özelliğin ayarlanmasının içe aktarılan tüm kontrollerin belirtilen türde olacağını garanti etmediğini unutmayın. Bir HTML kontrolü tercih edilen türdeki belge düğümleriyle temsil edilemiyorsa, Aspose.Words uyumlu bir türde kullanacaktır.HtmlControlType bu kontrol için.

Örnekler

İçe aktarılan <input> ve <select> öğelerini temsil edecek tercih edilen belge düğümü türünün nasıl ayarlanacağını gösterir.

const string html = @"
    <html>
        <select name='ComboBox' size='1'>
            <option value='val1'>item1</option>
            <option value='val2'></option>                        
        </select>
    </html>
";

HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
htmlLoadOptions.PreferredControlType = HtmlControlType.StructuredDocumentTag;

Document doc = new Document(new MemoryStream(Encoding.UTF8.GetBytes(html)), htmlLoadOptions);
NodeCollection nodes = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

StructuredDocumentTag tag = (StructuredDocumentTag) nodes[0];

Ayrıca bakınız