473,386 Members | 1,741 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,386 software developers and data experts.

[C#] Help with filling form fields in WebBrowser

First off, I'm using
  • C#
  • A WebBrowser Control
This is all inside the webbrowser
I'm trying to fill a text field with a variable (The variable works fine, everything checks out, but the text will not go into the field's value)
This is the html of the text field
[HTML]<div id="couponFormElement">
<div class="instructions">If you wish to apply a coupon code to your account, enter the coupon code in the field below, then click <strong>Apply</strong>.</div>

<div id="couponCode">
<input tabindex="21" type="text" name="coupon" value="" />
</div>[/HTML]
I've tried all three of these:
Expand|Select|Wrap|Line Numbers
  1. this.webBrowser1.Document.GetElementById("couponCode").SetAttribute("value", coupon);
  2. this.webBrowser1.Document.GetElementById("coupon").SetAttribute("value", coupon);
  3. this.webBrowser1.Document.GetElementById("couponFormElement").SetAttribute("value", coupon);
This the the site that I'm working with. If you don't have an account, just make one quickly and then signin. I'm trying to enter in to the field for Coupon Codes
https://rhapreg.real.com/rhapsody_ac...eal&page=login

If you could please give me some help, I've been scouring the internet for hours and tried everything i could find. Finally I got he nerve to join and post here.

Thanks ahead of time
Jul 31 '08 #1
3 6083
r035198x
13,262 8TB
Try giving the text field an id, say couponID, then using

Expand|Select|Wrap|Line Numbers
  1. this.webBrowser1.Document.GetElementById("couponID").SetAttribute("value", coupon);
Jul 31 '08 #2
Try giving the text field an id, say couponID, then using

Expand|Select|Wrap|Line Numbers
  1. this.webBrowser1.Document.GetElementById("couponID").SetAttribute("value", coupon);
Could you point me in the right direction?, I can't find a way to do that at all.
Jul 31 '08 #3
I recomend u to use the asp.net controls, the asp:textbox so u can refer it by code directly. it is a better server control.
[HTML]
<form id="form1" runat="server">
<div>
<asp:TextBox ID="IdTextbox" runat="server"></asp:TextBox>
</div>
</form>[/HTML]

in this way u can access the element easyly.

Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         this.IdTextbox.Text = "something";
  4.     }
luck with ur code
Jul 31 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
2
by: hennakapoor | last post by:
How do the form filling software determine which text field gets what data i.e. a typical form filling software will ask the user to enter the username / address / password etc. Whenever it goes to...
6
by: Brian | last post by:
Hello, Basically, I'm running a query on a form's activation, and I'd like to have the results of the query be placed into other fields on the same form automatically. Does anybody know how...
2
by: Cerebral Believer | last post by:
Hi folks, Can anyone help me with this form: http://futurebydesign-music.com/_member/club_fbd_reg.php I have followed to coding instructions aas closely as I can, but I am getting errors...
0
by: Balex | last post by:
hi, I have a VB.Net app which "reads" in html pages from a web server using winhttp. The purpose is for the app to "fill in" data fields on the page, then send it back to the web server, as if a...
1
by: Rotsey | last post by:
Hi, I have a form with a webbrowser control set to fill the form. I want to capture when the form is clicked. As the browser control is filling the form the user would click on the browser...
0
by: Rotsey | last post by:
Hi, I have a form with a webbrowser control set to fill the form. I want to capture when the form is clicked. As the browser control is filling the form the user would click on the browser...
11
by: kimiraikkonen | last post by:
Hi there, I needed to use MouseOver event on Webbrowser which is NOT provided by webbrowser control natively(what a disappointment), so i decided to go with another route to simulate this like: ...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.