HtmlElementErrorEventArgs.LineNumber 属性

定义

获取发生错误的 HTML 脚本代码行。

public:
 property int LineNumber { int get(); };
public int LineNumber { get; }
member this.LineNumber : int
Public ReadOnly Property LineNumber As Integer

属性值

一个用于指定脚本行号的 Int32

示例

下面的代码示例演示了此成员的用法。 在此示例中,事件处理程序报告事件的发生情况 HtmlWindow.Error 。 此报表可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑将 MessageBox.Show 替换为 Console.WriteLine 或将消息追加到多行 TextBox

若要运行示例代码,请将其粘贴到包含名为 HtmlWindow1的 类型的HtmlWindow实例的项目中。 然后,确保事件处理程序与 HtmlWindow.Error 事件相关联。

private void HtmlWindow1_Error(Object sender, HtmlElementErrorEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Description", e.Description );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Handled", e.Handled );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "LineNumber", e.LineNumber );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Url", e.Url );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Error Event" );
}
Private Sub HtmlWindow1_Error(sender as Object, e as HtmlElementErrorEventArgs) _ 
     Handles HtmlWindow1.Error

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Description", e.Description)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Handled", e.Handled)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "LineNumber", e.LineNumber)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Url", e.Url)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Error Event")

End Sub

适用于