using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(@"http://www.google.com");
//This code works well.This code will open Internet explorer and Navigate to google site.
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
I want when button2_Click is clicked the Internet explorer open this page(
button2_Click.
I am new to C# so plz give me the full code of [form1.cs] for this program.
Kirtan PatelPosted Oct 9, 2008, 10:48 AM
using System.Diagnostics;
See Mine ScreenShot
take text box named txtSource for writing ur source code you want to send to IE
take one button when u click it it will create one temp.html file using stream writer to current directory of ur program then
open the path of the currentdirectory\temp.html in IE
using System.Diagnosis
ie
Process.Start(path);
here is code i have written
private void button1_Click(object sender, EventArgs e)
{
// Get Current Directory Path
String currentdirectory = Environment.CurrentDirectory;
String path = currentdirectory+@"\temp.html";
// Get Text From TextBox to source variable
String source = txtSource.Text;
//create instance of Steam Writer
StreamWriter sw = new StreamWriter(path, false);
sw.Write(source);
sw.Close();
Process.Start(path);
}
Hope it will be helpful :)
Thanks
regards,
Kirtan Patel.
Daniel Innala AhlmarkPosted Oct 9, 2008, 2:47 AM
Use a StreamWriter to write the HTML-code to a .htm-file, which you then invoke with 'iexplore tempfile.htm', or perhaps even 'file://tempfile.htm' would work, if IE is the default browser.