Solved

Order code executes

Posted on 2013-10-30
4
395 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now