My problem is following: I try to open barcode online generator via WebBrowser and get barcode image. Here is my code:
/// <summary>
/// Main form of barcode server
/// </summary>
public partial class MainForm : Form
{
#region Constants
private const String BarCodeSite = "http://www.abarcode.net/online.aspx?barcode=EAN13";//"http://barcode.tec-it.com/en#";
#endregion
/// <summary>
/// Main form constructor
/// </summary>
public MainForm()
{
InitializeComponent();
}
/// <summary>
/// This event occured after form load
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_Load(object sender, EventArgs e)
{
webBrowser.Navigate(new Uri(BarCodeSite));
}
/// <summary>
/// Occurs when form is closing.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
barcodeServer.Abort();
}
catch (Exception ex)
{
// do nothing
}
}
private void button1_Click(object sender, EventArgs e)
{
var code = textBox1.Text;
var editText = webBrowser.Document.GetElementById("ValueToEncode");
editText.SetAttribute("Value", code.Trim(new char[] { '\0' }));
webBrowser.Document.GetElementById("Label13").InvokeMember("click");
}
}
What actions i perform: 1. Run my project 2. In options choose image zoom 250% 3. Paste into textBox1 controle code 8414034620202 4. Perform click on button1
Expected result: Barcode entered to the text field and image updated according to the entered barcode Actual result: Barcode entered to the text field, but image wasn't updated. I can't understand why my image doesn't update. Am I do something wrong?
Notes: Id "ValueToEncode" belongs to text field Id "Label13" belongs to text label with text "Data to encode:" Site I've used: http://www.abarcode.net/online.aspx?barcode=EAN13