-3

So I have everything working at this point but one. I am getting an error under webBrowser1. I am not sure why please help. I know that I was aske if I am declering everything so I will edit the code below to show everything in the form.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

private void Submit_Click (object sender, EventArgs e)
{
using (WebBrowser browser = new WebBrowser())
        {
            browser.Url = new Uri("http://www.google.com");
            HtmlElement textBox = webBrowser1.Document.All["textbox1"];
            if (textBox1 != null)
            {
                textBox.InnerText = textBox1.Text;
            }

        }
}

Am i missing something to make this work right. Please advise.

Shawn
  • 11
  • 7
  • 4
    So .. ? What's problem ? – Shumail Jul 22 '13 at 13:07
  • It says it right there. I am trying to do this and it is not working. I mean how cleare do you need it. The guy below understod as he gave me an answer. – Shawn Jul 22 '13 at 14:55
  • Dude - i gave answer. See my answer and comment over that. – Shumail Jul 22 '13 at 15:12
  • was not you sir. was the ones that placed it on hold as unclear. – Shawn Jul 22 '13 at 15:32
  • Can we do something about the nagative points on this. I mean evry one that answerd knew what i was asking. – Shawn Jul 22 '13 at 16:52
  • +1 from me ......@Shawn – Shumail Jul 22 '13 at 16:53
  • 1
    ya it is not you sir it is the ones that put it on hold, for what ever reason. You have been a big help up to this point and I than kyou for that. – Shawn Jul 22 '13 at 16:59
  • the hold is because you don't say what the problem is. you just say you are getting an error. was it a compile error? was it a runtime error, etc. you seem to have put some of that info into comments in several answers, but that doesn't help those of us just looking at the question itself. – John Gardner Jul 22 '13 at 17:40

3 Answers3

0

I guess one thing that it missing is .InnerText where you want to assign textBox content to textBox1.

if (textBox1 != null)
{
     textBox1.InnerText = textBox.InnerText;
}
TTT
  • 1,848
  • 2
  • 30
  • 60
0

In your example it looks like you've got your goal flipped around. Shouldn't it look like this instead:

if(textBox != null)
{
    textBox.innerText = textBox1.Text;
}
ermagana
  • 1,090
  • 6
  • 11
0

The issue is with your assignment. If you want to take input from textBox1 and assign it to html Textbox which is textBox, do it like as:

HtmlElement textBox = webBrowser1.Document.All["textbox1"];
if (textBox1 != null)
   {
      textBox.InnerText = textBox1.text;
   }
Shumail
  • 3,103
  • 4
  • 28
  • 35
  • so i have your answer in my C# program, but I am getting the red lines all over. It is giving me an error for webBrowser1, InnerText, and text after textBox1. I am not sure why. can you help – Shawn Jul 22 '13 at 15:40
  • May be you haven't set fields or added references properly as it's giving errors for variables. – Shumail Jul 22 '13 at 15:45
  • would that be something that I have to set at the top of the whole program in the using section. and if so what would it be set as. – Shawn Jul 22 '13 at 15:59
  • are you using VS 2012 ? – Shumail Jul 22 '13 at 16:51
  • I am sir. I am just not sure what I am doing wrong – Shawn Jul 22 '13 at 16:59
  • I posted every thing I have in the queston at the top sir. Please take a look and let me know what I am doing wrong. – Shawn Jul 22 '13 at 17:33
  • Apologies but there's no namespace , no Form, no class, no ``Form_load`` ? – Shumail Jul 22 '13 at 17:37
  • sorry about that was trying to take out the fluff. – Shawn Jul 22 '13 at 17:40
  • You need to study webbrowser control of c# - See this little guide. it will help you. Visit http://www.dotnetperls.com/webbrowser - I assume you didn't put `webbrowser`` object in form. See this answer as well.http://stackoverflow.com/questions/5716662/how-to-use-the-net-webbrowser-object – Shumail Jul 22 '13 at 17:41