Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0
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
Edited 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 at 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 at 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
0 OriginalGriff 400
1 CHill60 200
2 Sergey Alexandrovich Kryukov 170
3 RyanDev 135
4 arvind mepani 120


Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 30 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid