473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to fill in html textbox from windows application

Hey

I would like to do the following from a windows application:

1. Open a browser and navigate to a URL.
2. When i am at the correct URL in my browser window, i want to fill in data
in the html textboxes on that page from my windows application.
3. When thats done i want to press a button.
4. last i want to navigate to another URL.

Well, it seems like i did the first issue perfectly (i think), but working
on issue number 2 is killing me. How can i fill in my user input
automatically to my web browser from my windows application?

Ok, heres what i got so far:
SHDocVw.ShellWindows SWs = new SHDocVw.ShellWindows();
SHDocVw.InternetExplorer IExplorer = new
SHDocVw.InternetExplorer();

IExplorer.Visible = true;
IExplorer.Navigate(http://MyURL.asp, ref o, ref o, ref o, ref
o);

int counter = SWs.Count;

foreach (SHDocVw.InternetExplorer ie in SWs)
{
if (ie.LocationURL.ToString() == http://MyURL/SubPage.asp)
{
IHTMLDocument2 document = (IHTMLDocument2)ie.Document;
MessageBox.Show(document.all.tags("navn").ToString ());
//Gives me System.__ComObject???

//So far so good
//The following is simply just not working. Maybe im doing it all wrong??

HTMLTextElement navn =
(HTMLTextElement)document.all.tags("navn");
navn.innerText = "HEJ";

}
}

Anyone?

--
Jimmy
Nov 17 '05 #1
10 9442
Hi Jimmy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to put everything you input
from a Windows Form app into a web page and navigate to that page. If there
is any misunderstanding, please feel free to let me know.

Based on my experience, the best practice is to achieve this is to use 2
apps. One is winform app as currently used, the other is a web app which
converts the input data to an html page.

We can navigate to the web app's URL and pass the values of the winform
controls as query string. The web app gets the query string and display the
HTML page with values in the web browser.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #2
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> skrev i en meddelelse
news:Jf**************@TK2MSFTNGXA01.phx.gbl...
Hi Jimmy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to put everything you input
from a Windows Form app into a web page and navigate to that page. If
there
is any misunderstanding, please feel free to let me know.
I think you got it, but im gonna describe the steps included:

1. The win app should open a browser and navigate to a specific sites
loginURL (its my own web pages).
2. input the data for the username and password on the web pages form fields
3. press the login button on the web page
4. after a successfull login it should navigate to a specific web page
Based on my experience, the best practice is to achieve this is to use 2
apps. One is winform app as currently used, the other is a web app which
converts the input data to an html page.
That would require me to do some web development. I was actually trying to
avoid this, as many users are using these pages, and i wouldnt wanna change
anything on them.
We can navigate to the web app's URL and pass the values of the winform
controls as query string. The web app gets the query string and display
the
HTML page with values in the web browser.


I can see your point, but isnt it possible to input the data directly into
the fields on the web page from my win app.

If not, how du i post data from a win app to a web site?

thanks
Jimmy
Nov 17 '05 #3
"Jimbo" <ji***@nospam.nospam> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hey

I would like to do the following from a windows application:

1. Open a browser and navigate to a URL.
2. When i am at the correct URL in my browser window, i want to fill in
data in the html textboxes on that page from my windows application.
3. When thats done i want to press a button.
4. last i want to navigate to another URL.


Hey

Ok figured out point 2.

My probblem is now point 3. Seems like nothing that i do is working. How can
you simulate a click on a button (input type=image) from your win app.?
Jimmy
Nov 17 '05 #4
have a look at http://curl.haxx.se/

Nov 17 '05 #5
"Jimbo" <ji***@nospam.nospam> skrev i en meddelelse
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hey

I would like to do the following from a windows application:

1. Open a browser and navigate to a URL.
2. When i am at the correct URL in my browser window, i want to fill in
data in the html textboxes on that page from my windows application.
3. When thats done i want to press a button.
4. last i want to navigate to another URL.


Ok, seems like i have worked out all 4 points. Now i would like to create a
5th point.

5. When i have reached the URL at point 4, i would like to check once in a
while (say every 5 minutes), if the page is still running. If its not, i
will start all over. If it is running everythings fine. I use the objects in
SHDocVw.dll and mshtml.dll, but no matter what i do it seems like i cannot
check for this. If i get the standard error message in my Internet Explorer
window "the page could not be found" its like i still have access to the
full page, even though its not there anymore. I have access to all the
fields, the title and everything. So it seems like i cannot tell if the page
is running or not.
Anyone who can figure out how to check wether the page is running or not
through a windows application?

I would really apprieciate this.
Jimmy
Nov 17 '05 #6
Hi Jimmy,

Do you mean that you need to check if the IExplorer is still displaying? If
so, the only thing we can do is to check the LocationURL property of
IExplorer.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #7
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> skrev i en meddelelse
news:NL*************@TK2MSFTNGXA01.phx.gbl...
Hi Jimmy,

Do you mean that you need to check if the IExplorer is still displaying?
If
so, the only thing we can do is to check the LocationURL property of
IExplorer.


Yep, if the IExplorer is still displaying the correct page. Say the page im
on is http://Mywebsite/app.asp. When i check the LocationURL i should get
that address. I do, but heres the thing: When i disconnect my network
connection, and do a refresh on the page, or a navigate to the page for that
matter, Whats displayed in my browser window is "Page is not found". Then i
check the LocationURL property and it still says http://Mywebsite/app.asp.
Weird right?

Any suggestions?
Jimmy
Nov 17 '05 #8
Hi Jimbo,

This is the designed behavior of IE. Yes, although checking the LocationURL
property is not reliable, this is the only way to check if the page is
displaying as far as I know. You can also check the BeforeNavigate2 and
TitleChange event to make the checking more reliable. But there is no
absolutely reliable way to check for this.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #9
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> skrev i en meddelelse
news:an**************@TK2MSFTNGXA01.phx.gbl...
Hi Jimbo,

This is the designed behavior of IE. Yes, although checking the
LocationURL
property is not reliable, this is the only way to check if the page is
displaying as far as I know. You can also check the BeforeNavigate2 and
TitleChange event to make the checking more reliable. But there is no
absolutely reliable way to check for this.


Thanks Kevin

Instead i now try to get some values out of some fields at the correct HTML
page. if the fields is not there its gonna cause an exception wich i catch.
That seems to work altough im not glad that i couldnt do it the other way
around.

Thanks for your help :)
Jimmy
Nov 17 '05 #10
Hi Jimmy,

Yes, I agree with you that it's a workaround. But the con is that we have
to modify the code when the format of HTML page changes. Anyway, I'm glad
to hear that you have had this resolved.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Islam Elkhayat | last post by:
In my C# Web Application I need to fill a textbox with DataReader and use a Next Button to view next value... I created the Datareader in the Page_Load but everytime it get result of the First...
14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
17
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
2
by: Benny | last post by:
Is there a way to trace exceptions and messages captured with the Enterprise Library to a custom destination like a text box or any other control? If not can anyone think of a way to "hack"...
4
by: Finn Stampe Mikkelsen | last post by:
Hi Is there any way to make the textbox property show html, like a textarea on a webpage would?? I have a webapplication that saves an textarea complete with html tags and everything... ...
5
sid0404
by: sid0404 | last post by:
Hi I am new to the visualstudio.net I am trying to develop an application which requires me to send data to a HTML webpage - http://patft.uspto.gov/netahtml/PTO/search-bool.html and the user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.