Solved

Order code executes

Posted on 2013-10-30
4
419 Views
Last Modified: 2013-11-08
Hi guys,

I have the following on 2 different button clicks:

Button1:

WebBrowser_Sourcing_BrokerForum_Enquiry.Navigate(new Uri(" http://www.brokerforum.com/iris-parts-search.authenticated-en.jsa"));

Open in new window


Button2:

 try
            {


                var htmlDoc1 = (HTMLDocument)WebBrowser_Sourcing_BrokerForum_Enquiry.Document;


                var UsernameTextBox = (mshtml.HTMLInputElement)htmlDoc1.all.item("Session_Username", 0);
                UsernameTextBox.value = "XXXX";

                var PasswordTextBox = (mshtml.HTMLInputElement)htmlDoc1.all.item("Session_Password", 0);
                PasswordTextBox.value = "XXXX";



                foreach (mshtml.HTMLInputElement HTMLI in ((mshtml.HTMLDocument)WebBrowser_Sourcing_BrokerForum_Enquiry.Document).getElementsByTagName("input"))
                {

                    if (HTMLI.getAttribute("type").Equals("image"))
                    {
                        if (HTMLI.src == "http://www.brokerforum.com/tbf/img/login-button-en.png")
                        {

                            HTMLI.click();
                            return;
                        }
                    }


                }
            }

            catch (Exception) { }

Open in new window


This all works fine. But when I combine the 2 into a 'loaded' grid event the login never occurs. Why do they work separately on buttons but not when combined? Is it the order the code is executing?

Thanks,
Dean
0
Comment
Question by:deanlee17
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39611820
have you tried debugging it?

Set up a breakpoint, and see if they even get called in the first place
0
 

Author Comment

by:deanlee17
ID: 39611865
It does indeed.
0
 
LVL 15

Accepted Solution

by:
Ess Kay earned 500 total points
ID: 39612155
ah... perhaps the problem is the scope.

you need to use the keyword this.
everywhere

or this.parent.
 ...not sure which one but one of them will work

because it is looking for those objects withing the datagrid, not within the form.
You need to access the parent of the grid

ie:

this.WebBrowser_Sourcing_BrokerForum_Enquiry.Navigate(new Uri(" http://www.brokerforum.com/iris-parts-search.authenticated-en.jsa"));

or

this.parent.WebBrowser_Sourcing_BrokerForum_Enquiry.Navigate(new Uri(" http://www.brokerforum.com/iris-parts-search.authenticated-en.jsa"));
0
 

Author Comment

by:deanlee17
ID: 39613609
Nice idea, but it doesn't change anything.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question