Click here to Skip to main content
15,032,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:
C#
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
Updated 29-Jun-12 20:23pm
v4

1 solution

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

Good luck!
   
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)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900