Invoke click in a webbrowser element - html

I have a webbrowser control (name: WB) in my VB .net form.
I have loaded a webpage in webbrowser. Here is the sample html:
enter code here
<script type="text/javascript">
Sys.WebForms.PageRequestManager._initialize
('ctl00$ContentPlaceHolder1$ScriptManager1', 'form1',
['tctl00$ContentPlaceHolder1$UpdatePanel1',
'ContentPlaceHolder1_UpdatePanel1'], [], [], 90, 'ctl00');
</script>
<div class="row">
<div class="control group alternating">
<h2>Results</h2>
<div id="ContentPlaceHolder1_UpdatePanel1">
<div class="row">
<a id="ContentPlaceHolder1_Repeater1_LinkButton1_0"
href="javascript:__doPostBack('
ctl00$ContentPlaceHolder1$Repeater1$ctl00$LinkButton1','')">
<strong>A. Bleakley Chandler, MD</strong></a><br />
Georgia Medical College<br />Augusta, GA, USA
</div>
<div class="row">
<a id="ContentPlaceHolder1_Repeater1_LinkButton1_1"
href="javascript:__doPostBack('
ctl00$ContentPlaceHolder1$Repeater1$ctl01$LinkButton1','')">
<strong>A. Kyle Mack, MD</strong></a><br />
Ann and Robert H. Lurie Children's Hospital of Chicago<br />
</div>
<div class="row">
<a id="ContentPlaceHolder1_Repeater1_LinkButton1_2"
href="javascript:__doPostBack('
ctl00$ContentPlaceHolder1$Repeater1$ctl02$LinkButton1','')">
<strong>A. Lawrence Ossias, MD</strong></a><br />
Mount Sinai NYC<br />
</div>
<div class="row no-shading">
<div class="pagination-arrows right">
<span>
1 of 100</span>
<a id="ctl00_ContentPlaceHolder1_Repeater1Prev" class="aspNetDisabled ir
prev">prev</a>
<a id="ctl00_ContentPlaceHolder1_Repeater1Next" class="ir next"
href="javascript:__doPostBack('
ctl00$ContentPlaceHolder1$Repeater1Next','')">next</a>
</div>
</div>
</div>
Now I want to click on the first element of Repeater control. My InvokeMember code:
Dim pLink As HtmlElement = WB.Document.GetElementById
("ContentPlaceHolder1_Repeater1_LinkButton1_0")
pLink.InvokeMember("click") 'doesn't work
But due to some unknown reason, the click doesn't fire inside this repeater control. Other links in the page works fine with "invokemember("click")"
like the following one :
Dim pLink As HtmlElement = WB.Document.GetElementById
("ctl00_ContentPlaceHolder1_Repeater1Next")
pLink.InvokeMember("click") 'Works fine..
I tried GeckoFx browser control (geckoanchorelement.click), this did not work. I also tried to send MouseClick thru postmessage api - this also failed.

Related

'base.document.layout' object has no attribute 'header' odoo14 - trying to display custom fields in report

with a custom module, I have added the two fields header and footer to every res.company object. These are fields of the type binary.
I now want to display them in my document layout in qweb.
Unfortunately, odoo tells me
'base.document.layout' object has no attribute 'header'
This is what my layout looks like
<?xml version="1.0"?>
<t t-name="web.external_layout_boxed">
<div t-attf-class="header o_company_#{company.id}_layout" t-att-style="report_header_style">
<div class="o_boxed_header">
<div class="row mb8">
<div class="col-6">
<!--HERE--> <img t-if="company.logo" t-att-src="image_data_uri(company.header)" alt="brief_header"/>
</div>
<div class="col-6 text-right mb4">
<h4 class="mt0" t-field="company.report_header"/>
<div name="company_address" class="float-right mb4">
<span class="company_address" t-field="company.partner_id" t-options="{"widget": "contact", "fields": ["address", "name"], "no_marker": true}"/>
</div>
</div>
</div>
</div>
</div>
<div t-attf-class="article o_report_layout_boxed o_company_#{company.id}_layout" t-att-data-oe-model="o and o._name" t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')">
<div class="pt-5">
<t t-call="web.address_layout"/>
</div>
<t t-raw="0"/>
</div>
<img t-if="company.logo" t-att-src="image_data_uri(company.footer)" alt="brief_footer"/>
</t>
as you can see I am trying to access the header with company.header
the pictures appended show you that the fields exist on the type.
What am I doing wrong? How can I correctly display the uploaded images in the external_layout_boxed?
When rendering the document, the company variable is set to wizard object not to the user company. Odoo will try to access header and footer in base.document.layout model.
To fix that issue, alter the document layout model like following:
class BaseDocumentLayout(models.TransientModel):
_inherit = 'base.document.layout'
header = fields.Binary(related="company_id.header")
footer = fields.Binary(related="company_id.footer")
You can find an example in l10n_de module where they created a new report layout and altered base.document.layout to use new fields like street, city or bank_ids

How to scrape mailto from following page using VBA

i am trying to scrape mailto (href) from a html file, but i am unable to "hit" it.
Any advice is welcome.
<div class="exhibitor-contact">
<div class="col">
<h3>
whatever </h3>
<p>
MLW <br /> whatever<br /> 75008 Paris - France </p>
<p>
<a class='inverse-a-span' href='#tel' id='tel' onclick="return xt_click(this,'C', xtn2, xtpage.replace(/\w*$/, 'exhibitor::tel').replace(/^Exhibitors::/, ''), 'A')">Show Phone Number</a><span style='display:none;'>whatever</span><br /> Send an Email<br /> </p>
</div>
</div>
</section>
Code:
Set my_data = IE.Document.getElementsByClassName("anyclass")
Set mail = IE.Document.getElementsByTagName("a")(0) ActiveSheet.Cells(i, 2).Value = mail.href
Use a css attribute = value selector with ^ starts with operator
Debug.Print ie.document.querySelector("[href^='mailto:']").href

routerLink from Object in Angular2

I'm trying to build a "Team Member" page from JSON data.
I can create the page with basic things like firstName, lastName, position.
Each team member has their own page with a little more information
What I cant figure out is how to include the team members url to my [routerLink].
My router link would look like this which I have setup in my routes
<a [routerLink]="['./glenn']">
And this is how I'm attempting to use it
<div class="team-members" *ngFor="let teammember of teammembers" >
<div class="clearfix">
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6 team-member member-item" style="cursor: pointer;">
<a [routerLink]="['./"{{teammember.firstName}}"']">
<div class="member-pic-holder">
<img alt="" src='{{teammember.photo}}' />
<div class="member-overlay"></div>
</div>
<h4>{{teammember.firstName}}<br/>{{teammember.lastName}} <span class="fa fa-arrow-right"></span></h4>
<p class="company-position">{{teammember.position}}</p>
</a>
</div>
</div>
</div>
Any thoughts on this one please?
It's also breaking when I'm trying to include the team-members photo
<img alt="" src='{{teammember.photo}}' />
However one thing at a time!
Thanks
GWS
You are using the {{ foo.bar }} binding incorrectly, the {{ }} syntax allows you to do one way binding, what you want is to use regular js expressions when binding to your objects properties.
When binding to an html element attribute, you can use the [attr.{id|href|etc}] binding, in your case, for the href of the image you can use:
<img alt="" [attr.href] = 'teammember.photo' />
And for the router, simply use [routerLink] = "[teammember.firstName]" (not sure why you need the ./, if you do need it, you could append it using a getter on your team member class, as shown bellow.
For your routes, you could do something along the lines of:
Team Member Class
export class TeamMember {
// ...properties and constructor
private memberUrl: string = "foobar"
get MemberRoute(){
return `./${this.memberUrl}`;
}
}
Template:
<div class="team-members" *ngFor="let teammember of teammembers" >
<div class="clearfix">
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-6 team-member member-item" style="cursor: pointer;">
<a [routerLink]="[teammember.MemberRoute']">
<div class="member-pic-holder">
<img [attr.href] = 'teammember.photo' />
<div class="member-overlay"></div>
</div>
<h4>{{teammember.firstName}}<br/>{{teammember.lastName}} <span class="fa fa-arrow-right"></span></h4>
<p class="company-position">{{teammember.position}}</p>
</a>
</div>
</div>
</div>
Hope this helps!
can you try like this:
['./',teammember.firstName]
for img use
<img alt="" [src]="teammember.photo" />

Passing a variable to href

I have this code that is getting data from a cell in a table
<div class="p-s-header">TITLE</div>
<div class="p-content">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<span di="76" ></span><br />
<span di="77" ></span><br />
</div>
</div>
</div>
This is producing:
TITLE
(data in cell 76)
(DATA in cell 77)
Now, data in cell 77 is a a link that is too long for the space, so I want to add the work "Click here" (hyperlinked) instead of showing the link.
So I wanted to change code, so output looks like:
TITLE
(data in cell 76)
Click here
"Click here" shoudl be built with the data in cell 77. I didn't code this but it seems the code to get the data from that cell is:
How would I build it?
I tried a few options, but nothing seems to work:
For example something like this:
<a href=<span di="77" ></span>Link</a><br />
thanks for your help
Try this, I hope this will encourage you on studying further how HTML and JS work together. (PHP is too advanced right now).
Change your code for this:
<div class="p-s-header">TITLE</div>
<div class="p-content">
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<span id="cell76" ></span><br />
<span id="cell77" >http://www.google.com</span><br />
</div>
</div>
</div>
The attribute di doesn't exist, it is id and id's cannot start with numbers or be numbers
At the bottom of the code that you added write the following:
<script>
var link = document.getElementById('cell77').innerHTML;
document.write(''+link+'');
</script>
Here is the jsfiddle
https://jsfiddle.net/cz1Ltw3x/1/

ng-if and ng-show in my Ionic application, neither works

The html code goes something like this:
<div ng-if="name=='John'">
<div class="item item-avatar"> <img ng-src="john.jpg"></div>
</div>
<div ng-if="name=='Margaret'"
<div class="item item-avatar"> <img ng-src="margaret.jpg"></div>
</div>
Instead of ng-if, I've tried using ng-show as well. Neither worked. Both John as well as Margaret showed on the page no matter which I used. I tried with ng-switch also.
The variable 'name' I initialized earlier on the same HTML file as:
<a class="item item-avatar item-icon-right" ng-init="name = 'John'" href = "#/Page3"></a>
Clicking on the above line leads to Page3 where I need to display either John or Margaret depending on the value of 'name'.
Is the syntax wrong or something, because that could be very well possible. I'm new to Ionic and AngularJS.
Try this:
<div ng-show="name=='John'" ng-init="name = 'John'">
<div class="item item-avatar"> John</div>
</div>
<div ng-show="name=='Margaret'"
<div class="item item-avatar"> Margaret</div>
</div>
Works for me. I just change ng-if to ng-show - which will shows div content when true and hide it otherwise. I also use ng-init inside a div.
Are you sure you started Angular? Did you set the ng-app directive?
It would help if you could provide a working example if you have other problems.
angular.module('app', []);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-init="name = 'John'">
<button type="button" ng-click="name='John'">John</button>
<button type="button" ng-click="name='Margaret'">Margaret</button>
<div ng-if="name=='John'">
This is John
</div>
<div ng-if="name=='Margaret'">
This is Margaret
</div>
</div>
I fixed you plunker - now it should be working.
Bug #1: ng-init is for initialization not to set values at runtime -> use ng-click instead
Bug #2: You use the same controller for all pages but for each page a new controller will be initialized, which resets the 'name' property
I implemented a setName function to set the name in the rootscope and to go to page3. In a correct implementation you should pass the name as a $stateparam to the new state/page. But for that please have a look at the ui-router documentation.
$scope.setName = function(name) {
console.log(name);
$rootScope.name = name;
$state.go('Page3');
};