| | |
Getting text in textbox(in webbrowser control)
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2009
Posts: 3
Reputation:
Solved Threads: 0
Hi.
I am using a webbrowser control in my form program and i am displaying an html page. There is 1 textbox in html page and id is "textbox". When someone write something in textbox, i want to use this text and save it to db. It will be work like this; somebody is writing somethings in textbox(in html page) and when press the button(form button), i want to save this text.
How can i do that?
I am using a webbrowser control in my form program and i am displaying an html page. There is 1 textbox in html page and id is "textbox". When someone write something in textbox, i want to use this text and save it to db. It will be work like this; somebody is writing somethings in textbox(in html page) and when press the button(form button), i want to save this text.
How can i do that?
•
•
Join Date: Sep 2009
Posts: 3
Reputation:
Solved Threads: 0
Alok, I think you didnt read carefully(:
The textbox is in html page. There is a webbrowser control and it has a textbox(in html page) and then in form, there is a button. When a user write "example" in textbox(in html page), and then click the button, I want to catch this "example".
string txt = ...................; ----> txt must be what user write in textbox.
The textbox is in html page. There is a webbrowser control and it has a textbox(in html page) and then in form, there is a button. When a user write "example" in textbox(in html page), and then click the button, I want to catch this "example".
string txt = ...................; ----> txt must be what user write in textbox.
•
•
Join Date: Jan 2008
Posts: 2,052
Reputation:
Solved Threads: 118
see the attached project too :
Form1.cs :
Form1.Designer.cs :
pageWithTextBox.htm :
Form1.cs :
C# Syntax (Toggle Plain Text)
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Reflection; namespace GetTextInTextBox { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnGetText_Click(object sender, EventArgs e) { MessageBox.Show(webBrowser1.Document.GetElementById("textbox").GetAttribute("value")); } private void Form1_Load(object sender, EventArgs e) { webBrowser1.Url = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "pageWithTextBox.htm")); } } }
Form1.Designer.cs :
C# Syntax (Toggle Plain Text)
namespace GetTextInTextBox { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.webBrowser1 = new System.Windows.Forms.WebBrowser(); this.btnGetText = new System.Windows.Forms.Button(); this.SuspendLayout(); // // webBrowser1 // this.webBrowser1.Location = new System.Drawing.Point(25, 12); this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20); this.webBrowser1.Name = "webBrowser1"; this.webBrowser1.Size = new System.Drawing.Size(250, 250); this.webBrowser1.TabIndex = 0; this.webBrowser1.Url = new System.Uri("", System.UriKind.Relative); // // btnGetText // this.btnGetText.Location = new System.Drawing.Point(305, 35); this.btnGetText.Name = "btnGetText"; this.btnGetText.Size = new System.Drawing.Size(75, 23); this.btnGetText.TabIndex = 1; this.btnGetText.Text = "Get Text"; this.btnGetText.UseVisualStyleBackColor = true; this.btnGetText.Click += new System.EventHandler(this.btnGetText_Click); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(454, 291); this.Controls.Add(this.btnGetText); this.Controls.Add(this.webBrowser1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false); } #endregion private System.Windows.Forms.WebBrowser webBrowser1; private System.Windows.Forms.Button btnGetText; } }
pageWithTextBox.htm :
C# Syntax (Toggle Plain Text)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title></title> </head> <body> <input id="textbox" type="text" /> </body> </html>
Due to lack of freedom of speech, i no longer post on this website.
![]() |
Similar Threads
- how to dynamically set the text of a label using the text from textbox? (ASP.NET)
- IWebproxy and Webbrowser Control (VB.NET)
- How to change bgcolor of webbrowser control? (C#)
- Comparison of text in textbox (VB.NET)
- How to control where to fprintf string? (C++)
- New textbox in user control broke datagrid sorting (ASP.NET)
- Import text into ListView? (C#)
- Can images be auto-resized while using the WebBrowser control in VB5 (Visual Basic 4 / 5 / 6)
- Using WebBrowser Control in Win32 (C)
Other Threads in the C# Forum
- Previous Thread: Adding Row To DatagridView
- Next Thread: Mounting ISO in C#
| Thread Tools | Search this Thread |
.net 2007 access activedirectory algorithm array barchart bitmap box broadcast c# check checkbox client combobox control conversion cryptographyc#winformsencryption csharp custom database datagrid datagridview dataset date datetime degrees development disabled displayingopenforms draganddrop drawing encryption enum eventcloseformc# excel file foreach form format forms ftp function gdi+ image index index-error input install java label list listbox listener listview load mandelbrot math mathematics mouseclick mysql operator path photoshop picturebox pixelinversion post prime programming radians regex remoting richtextbox security server setup sleep socket sql statistics stream string table text textbox thread time timer totaldays update user usercontrol validation visual visualstudio webbrowser windows winforms wpf xml






