Button click c#

Add-in Express™ Support Service
That's what is more important than anything else

Button click c#
event for the result of my search  
Georges DEME




Posts: 18
Joined: 2017-03-07
Hi ,

I am a C# developer, I have a page that I want to get the data by using GetElementByID.

But when I type the Sku number in the text box and hit the button Search, when the result come out , I am not able to get the data by using GetElementByID.

In which event I can go to see the result of my search.

Thanks!
Georges
Posted 07 Mar, 2017 14:48:50 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Georges,

I guess that the web page is completely reloaded and you use the wrong id in the GetElementByID method. Can you please send me a simple project that reproduces the issue?
Posted 09 Mar, 2017 04:21:12 Top
Georges DEME




Posts: 18
Joined: 2017-03-07
Hi,

I want to get the data by GetElementByID on the Page2. But on the event OnDocumentComplete2 the HTMLDocument keep the data of the Page1. Can you help me to pass the data of the Page2 in the HTMLDocument , so I can get the data of the page2.

Thanks
Georges

Add-in Express.com support request {ID:279045180} , there I added the images.

using System;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Windows.Forms;
using IE = Interop.SHDocVw;
using AddinExpress.IE;
using mshtml;
using System.IO;

namespace NorAmExtension
{
/// <summary>
/// Add-in Express for Internet Explorer Module
/// </summary>
[ComVisible(true), Guid("706A19BE-8F6C-45F6-8175-43E360393C6E")]
public class IEModule : AddinExpress.IE.ADXIEModule
{
public IEModule()
{
InitializeComponent();
//Please write any initialization code in the OnConnect event handler
// MessageBox.Show("Page init IEModule()");
}

private ADXIEHTMLDocEvents adxiehtmlDocEvents1;

public IEModule(IContainer container)
{
container.Add(this);

InitializeComponent();
//Please write any initialization code in the OnConnect event handler
MessageBox.Show("Page IEModule(IContainer container)");
}



//}

#region Component Designer generated code
/// <summary>
/// Required by designer
/// </summary>
private System.ComponentModel.IContainer components;

/// <summary>
/// Required by designer support - do not modify
/// the following method
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.adxiehtmlDocEvents1 = new AddinExpress.IE.ADXIEHTMLDocEvents(this.components);
//
// adxiehtmlDocEvents1
//

this.adxiehtmlDocEvents1.OnClick += new AddinExpress.IE.ADXIEHTMLEventObjectEx_EventHandler(this.adxiehtmlDocEvents1_OnClick);
//
// IEModule
//
this.HandleShortcuts = true;
this.LoadInMainProcess = false;
this.HandleHTTPNegotiations = true;
this.ModuleName = "NorAmExtension";
}

private void IEModule_DocumentComplete(object pDisp, string url)
{
MessageBox.Show("DocumentComplete");
}

#endregion

#region ADX automatic code

// Required by Add-in Express - do not modify
// the methods within this region

public override System.ComponentModel.IContainer GetContainer()
{
if (components == null)
components = new System.ComponentModel.Container();
return components;
}

[ComRegisterFunctionAttribute]
public static void RegisterIEModule(Type t)
{
AddinExpress.IE.ADXIEModule.RegisterIEModuleInternal(t);
}

[ComUnregisterFunctionAttribute]
public static void UnregisterIEModule(Type t)
{
AddinExpress.IE.ADXIEModule.UnregisterIEModuleInternal(t);
}

[ComVisible(true)]
public class IECustomContextMenuCommands :
AddinExpress.IE.ADXIEModule.ADXIEContextMenuCommandDispatcher
{
}

[ComVisible(true)]
public class IECustomCommands :
AddinExpress.IE.ADXIEModule.ADXIECommandDispatcher
{
}

#endregion

public IE.WebBrowser IEApp
{
get
{
MessageBox.Show("salut georges la page IEApp est chargee");
return (this.IEObj as IE.WebBrowser);
}
}

public mshtml.HTMLDocument HTMLDocument
{
get
{
MessageBox.Show("*** Page HTMLDocument loaded ***");
return (this.HTMLDocumentObj as mshtml.HTMLDocument);
}
}



private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, ADXCancelEventArgs e)
{
MessageBox.Show("The Click was fired");
if (HTMLDocument.url == "https://hstt.com/CheckIn/CheckIn")
{
this.DocumentComplete2 += new AddinExpress.IE.ADXIEDocumentComplete2_EventHandler(this.IEModule_DocumentComplete2);
}


}


private void IEModule_DocumentComplete2(object pDisp, string url, bool rootDocLoaded)
{
if (HTMLDocument.url == "https://hstt.com/CheckIn/CheckIn")
{
MessageBox.Show("*********************DocumentComplete2**********************************");

MessageBox.Show(HTMLDocumentText); // Here I want to see the result of my search
}


}
}
}
Posted 09 Mar, 2017 09:37:35 Top
Sergey Grischenko


Add-in Express team


Posts: 7187
Joined: 2004-07-05
Hi Georges,

Please use the 'rootDocLoaded' parameter to perform your code after the new page is opened.
E.g.

private void IEModule_DocumentComplete2(object pDisp, string url, bool rootDocLoaded)
{
if (rootDocLoaded)
{
if (HTMLDocument.url == "https://hstt.com/CheckIn/CheckIn")
{
MessageBox.Show("*********************DocumentComplete2**********************************");
MessageBox.Show(HTMLDocumentText); // Here I want to see the result of my search
}
}
}

Also, there is no need to connect to DocumentComplete2 event manually in the adxiehtmlDocEvents1_OnClick event handler. Add-in Express will connect all events automatically.
Posted 10 Mar, 2017 11:10:16 Top
Georges DEME




Posts: 18
Joined: 2017-03-07
Thanks Sergey for your response is working now.

I got an other question is: How to get the id button in a click event ?

I want to get the name of the button clicked.

private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, ADXCancelEventArgs e)
{

}
Posted 13 Mar, 2017 10:13:38 Top
Andrei Smolin


Add-in Express team


Posts: 14126
Joined: 2006-05-11
Hello Georges,

Here's the idea:
private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, AddinExpress.IE.ADXCancelEventArgs e)
{
    mshtml.IHTMLEventObj2 obj = eventObject as mshtml.IHTMLEventObj2;
    if (obj != null)
    {
        mshtml.IHTMLElement elem =
            this.HTMLDocument.elementFromPoint(obj.x, obj.y);

        if (elem != null)
            MessageBox.Show(elem.tagName);
    }
} 


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 14 Mar, 2017 06:00:35 Top
Georges DEME




Posts: 18
Joined: 2017-03-07
Thanks Andrei, that's perfect ! I am learning every day with you guys.

But how can I get in that example only the "Log On" ?

<input name="Command" type="submit" value="Log On">
Posted 14 Mar, 2017 11:04:42 Top
Andrei Smolin


Add-in Express team


Posts: 14126
Joined: 2006-05-11
Hello Georges,

private void adxiehtmlDocEvents1_OnClick(object sender, object eventObject, ADXCancelEventArgs e) {
    mshtml.IHTMLEventObj2 obj = eventObject as mshtml.IHTMLEventObj2;
    if (obj != null) {
        mshtml.IHTMLElement elem =
            this.HTMLDocument.elementFromPoint(obj.x, obj.y);

        if (elem != null) {
            MessageBox.Show(elem.tagName);
            mshtml.HTMLInputElement input = elem as mshtml.HTMLInputElement;
            MessageBox.Show(input.value);
        }
    }
}



Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 15 Mar, 2017 06:01:26 Top
Georges DEME




Posts: 18
Joined: 2017-03-07
Thanks Andrei, is working.
Posted 15 Mar, 2017 17:49:53 Top
Georges DEME




Posts: 18
Joined: 2017-03-07
Hi Andrei,

As you help me for the click, How to get those values in the DocumentComplete2 event ?

<input id="CheckInSearch_LicensePlate" name="CheckInSearch.LicensePlate" type="hidden" value="LPKEN000000214228000" />
<input id="CheckInSearch_CPORDNumber" name="CheckInSearch.CPORDNumber" type="hidden" value="OREUSA2318077683DE" />
<input data-val="true" data-val-required="The Is Damaged field is required." id="CheckInSearch_IsDamaged" name="CheckInSearch.IsDamaged" type="hidden" value="False" />
<input data-val="true" data-val-required="The Is Unidentifiable field is required." id="CheckInSearch_Unidentified" name="CheckInSearch.Unidentified" type="hidden" value="False" />
<input id="PIPInfoAggregate_NextRoutingDisposition_Description" name="PIPInfoAggregate.NextRoutingDisposition.Description" type="hidden" value="OpenBox" />


Thanks
Georges
Posted 15 Mar, 2017 18:35:57 Top