473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
Jul 17 '07 #1
2 1237
Atran
319 100+
Hello:
Create a new win project. Make two forms. Dont change the forms name.
Write this code to Form1 code:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace WindowsApplication1
  6. {
  7.     public partial class Form1 : Form
  8.     {
  9.         //Creating a new Form2.
  10.         Form2 f2 = new Form2();
  11.         //Creating a new button.
  12.         Button btn = new Button();
  13.         public Form1()
  14.         {
  15.             InitializeComponent();
  16.             //Creating a new eventhandler.
  17.             this.Load += new EventHandler(Form1_Load);
  18.  
  19.             //btn properties.
  20.             btn.Location = new Point(12, 12);
  21.             btn.Text = "Refresh";
  22.             //btn click event handler.
  23.             btn.Click += new EventHandler(btn_Click);
  24.             //Add btn to the form1.
  25.             Controls.Add(btn);
  26.         }
  27.  
  28.         void btn_Click(object sender, EventArgs e)
  29.         {
  30.             //Refresh the web browser  in Form2.
  31.             //wb is the webBrowser in form2.
  32.             f2.wb.Refresh();
  33.         }
  34.  
  35.         void Form1_Load(object sender, EventArgs e)
  36.         {
  37.             //Show Form2.
  38.             f2.Show();
  39.         }
  40.     }
  41. }
  42.  
And write this code to Form2:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4.  
  5. namespace WindowsApplication1
  6. {
  7.     public partial class Form2 : Form
  8.     {
  9.         //Creating a new WebBrowser.
  10.         //wb is a new WebBrowser.
  11.         public WebBrowser wb = new WebBrowser();
  12.         public Form2()
  13.         {
  14.             InitializeComponent();
  15.  
  16.             //wb properties.
  17.             wb.Location = new Point(12, 12);
  18.             wb.Size = new Size(250, 200);
  19.             wb.Url = new System.Uri("http://www.thescripts.com/", System.UriKind.Absolute);
  20.             Controls.Add(wb);
  21.         }
  22.     }
  23. }
  24.  
Hope I helped you.
Jul 17 '07 #2
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Events Between Web Forms
Jul 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Scott | last post by:
I have a clickable graph that resides on page 1. If user clicks a data point on the graph, the page runs again yeilding a 2nd graph that shows a more detailed graph. Problem is, I have a...
1
by: Marco Maroni | last post by:
How to force image refresh on client browser ? Is ti possible to force the refresh of the same image (tha was changed server-side) to the client, without user press Contrl+F5 in IE ? - Marco
2
by: Jeronimo Bertran | last post by:
Hi, I have a page with a very data intensive grid which needs to be automatically refreshed constantly if a change is detected. In order to not refresh the complete page so often, I created an...
1
by: francois | last post by:
I have a ASPX form with a dropdownlist that makes a post back (to the same page of course, just a normal asp.net postback) That page also has an auto refresh javascript as it needs to refresh its...
9
by: PK9 | last post by:
I'm having an issue with the "Refresh" of an asp.net page. The refresh is actually calling my last onClick event. I thought that asp.net was supposed to be stateless in that it shouldn't...
0
by: Brad White | last post by:
Overview: I have a custom web app that has an 'Inbox' that refreshes every 30 seconds. One user uses Outlook to host the web page. Using IE, the refresh works fine. If the user is working in...
3
by: Kevin | last post by:
Hi guys, I want to refresh some pages every 2 seconds. however, these html pages are not in my site, they could be any pages from yahoo.com or msn.com. I can create a page, which redirect to...
8
by: Jason S | last post by:
Hi, is there any way of getting my VB (6.0) program to automatically 'Refresh' an IE window that might be active (window status not applicable). It needs to be able to determine which active IE...
10
by: phforum | last post by:
Hi, I wrote a PHP page for user input the information to search the database. And the database data will update every second. I want to set the auto refresh to get the data from database every...
5
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I used the following code to refresh the parent page, and it works very well (Thanks to Peter Bromberg "). Response.Write("<script language='javascript' type='text/javascript'{...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.