Notifications
Clear all

[Closed] Webbrowser AttachEventHandler of element event problem in maxscript

Hi,I am using an ajax to refresh a webbrowser page to get data for my recently project.(From this thread’s suggestion.)
I want to use an event to detect if the page refreshed or not.
After searched,it seems the “onpropertychange” event can handle this:(C#)

private void handlerAbc(Object sender, EventArgs e)
{
    HtmlElement elm = webBrowser1.Document.GetElementById("abc");
    if (elm == null) return;
    Console.WriteLine("elm.InnerHtml(handlerAbc):" + elm.InnerHtml);
} 
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    System.IO.StreamReader getReader = new System.IO.StreamReader(webBrowser1.DocumentStream, System.Text.Encoding.Default);
    HtmlElement elm = webBrowser1.Document.GetElementById("abc"); 
    Console.WriteLine("elm.InnerHtml(DocumentCompleted):" + elm.InnerHtml);
    if (elm != null)
    {
        elm.AttachEventHandler("onpropertychange", new EventHandler(handlerAbc));
    } 
}

I got an error when using AttachEventHandler event:(Maxscript)


(
   chk_url="the update url"
   try(destroydialog max_test) catch()
   rollout max_test "Update data"
   (      
      dotNetControl wb "System.Windows.forms.WebBrowser" pos:[10,22] width:580 height:570
      Fn elm_change sender ev=
      (
         print (wb.Document.GetElementById "abc").InnerText
      )
      on max_test open do
      (
         wb.url=dotNetObject "System.Uri" chk_url
      )
      on wb DocumentCompleted arg do 
      (
         elm=wb.Document.GetElementById "abc"
         dotNet.addEventHandler elm "MouseDown" elm_change --work
         
         --dotNet.addEventHandler elm "OnPropertyChange" elm_change  -- Runtime error: No method found which matched argument list << 
         --[b]elm.AttachEventHandler "OnPropertyChange" elm_change[/b]          -- Runtime error: No method found which matched argument list <<
         --showmethods elm
      )
   )
   CreateDialog max_test 580 500
)

Showmethods element:

  .<System.Windows.Forms.HtmlElement>AppendChild <System.Windows.Forms.HtmlElement>newElement
[b]  .AttachEventHandler <System.String>eventName <System.EventHandler>eventHandler[/b]
  .DetachEventHandler <System.String>eventName <System.EventHandler>eventHandler
  .<System.Boolean>Equals <System.Object>obj
  .[static]<System.Boolean>Equals <System.Object>objA <System.Object>objB
  .Focus()
  .<System.String>GetAttribute <System.String>attributeName
  .<System.Windows.Forms.HtmlElementCollection>GetElementsByTagName <System.String>tagName
  .<System.Int32>GetHashCode()
  .<System.Type>GetType()
  .<System.Windows.Forms.HtmlElement>InsertAdjacentElement <System.Windows.Forms.HtmlElementInsertionOrientation>orient <System.Windows.Forms.HtmlElement>newElement
  .<System.Object>InvokeMember <System.String>methodName
  .<System.Object>InvokeMember <System.String>methodName <System.Object[]>parameter
  .RaiseEvent <System.String>eventName
  .[static]<System.Boolean>ReferenceEquals <System.Object>objA <System.Object>objB
  .RemoveFocus()
  .ScrollIntoView <System.Boolean>alignWithTop
  .SetAttribute <System.String>attributeName <System.String>value
  .<System.String>ToString()

How shall I fix it?Any help would be appreciated!