How we refresh a web page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shaileshsharma
    New Member
    • Jun 2007
    • 26

    How we refresh a web page

    Hi,
    I have two form FORM A and FORM B. a button called btnreffresh is on FORM A. I want when i click on refresh button FORM B should be refresh.
    This can be possible in c#.

    Shailesh Kumar
  • Atran
    Contributor
    • May 2007
    • 319

    #2
    Hello:
    Create a new win project. Make two forms. Dont change the forms name.
    Write this code to Form1 code:
    Code:
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            //Creating a new Form2.
            Form2 f2 = new Form2();
            //Creating a new button.
            Button btn = new Button();
            public Form1()
            {
                InitializeComponent();
                //Creating a new eventhandler.
                this.Load += new EventHandler(Form1_Load);
    
                //btn properties.
                btn.Location = new Point(12, 12);
                btn.Text = "Refresh";
                //btn click event handler.
                btn.Click += new EventHandler(btn_Click);
                //Add btn to the form1.
                Controls.Add(btn);
            }
    
            void btn_Click(object sender, EventArgs e)
            {
                //Refresh the web browser  in Form2.
                //wb is the webBrowser in form2.
                f2.wb.Refresh();
            }
    
            void Form1_Load(object sender, EventArgs e)
            {
                //Show Form2.
                f2.Show();
            }
        }
    }
    And write this code to Form2:
    Code:
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace WindowsApplication1
    {
        public partial class Form2 : Form
        {
            //Creating a new WebBrowser.
            //wb is a new WebBrowser.
            public WebBrowser wb = new WebBrowser();
            public Form2()
            {
                InitializeComponent();
                
                //wb properties.
                wb.Location = new Point(12, 12);
                wb.Size = new Size(250, 200);
                wb.Url = new System.Uri("http://www.thescripts.com/", System.UriKind.Absolute);
                Controls.Add(wb);
            }
        }
    }
    Hope I helped you.

    Comment

    • kenobewan
      Recognized Expert Specialist
      • Dec 2006
      • 4871

      #3
      Here is an article that may help:
      Events Between Web Forms

      Comment

      Working...