Click here to Skip to main content
13,087,235 members (55,188 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hello
I m doing one windows application where i used web browser control,button for connecting URL, textbox for search data in my form. I navigate webbrowser control to one of the dataentry website. I have the data in my database like name, address city, dbo, district etc.
what i m doing i search data from database on name criteria and getting all values in dataset then using 'SendKey' i send that searched data to the particular fields of the website and it works also.The problem is that it works for the textbox control of the website but not for the dropdown control. I used the 'Tab' key for sending data.That website Using Dropdown Control for City,State,Country, Gender etc. Whenever i select some item from dropdown control it postback every time and load page every time. To avoid postbacking and reloading in website i try to make this application.

Below is My COde:
private void fillData()
{
 //Code for searching the record against 'CustomerName'
         if (dSet.Tables[0].Rows[0]["DistrictName"] != DBNull.Value)         //Dropdown Control
         SendKeys.Send(dSet.Tables[0].Rows[0]["DistrictName"].ToString().Trim());
         WaitFor();
         SendKeys.Send("{TAB}");
         SendKeys.Send(dSet.Tables[0].Rows[0]["City"].ToString().Trim());
         WaitFor();
        SendKeys.Send("{TAB}");
        SendKeys.Send(dSet.Tables[0].Rows[0]["SpouseName"].ToString().Trim()); //Textbox Control
        WaitFor();
        // and So Many Fields..
       WaitFor();
       GC.Collect();
}
 
private void WaitFor()
        {
            for (int i = 0; i <= 5000; i++)
            {
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
                Application.DoEvents();
            }
        }

Plz help me out what i do for sending data in dropdown control.

Regards
Maahi
Posted 29-Jun-12 3:59am
Updated 29-Jun-12 20:23pm
v4

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Your code is windows forms and not asp.net. Try set CauseValidation to false for those controls.

Good luck!
  Permalink  
Comments
Maahi Sawarkar 29-Jun-12 11:09am
   
I didnt developed that website. Also i dont Know the controls name. Then how could i set causevalidation false for those controls. i m only navigate that website in my Browsercontrol.
E.F. Nijboer 30-Jun-12 12:08pm
   
Ah, ok. didn't quite get that. But wouldn't it be much easier to set the fields directly? You can just do:
WebBrowser1.Document.GetElementById("DistrictName").SetAttribute("Value", "Districtname from dataset")

http://vbcity.com/blogs/jatkinson/archive/2009/12/12/programmatically-entering-and-data-using-the-webbrowser-control.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 30 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100