Updating a page from another page without refreshing the page

1.6k views Asked by At

I have two web pages written in VisualBasic.Net:

  • Upload.aspx
  • Default.aspx

There is a link in the Default page that opens Upload page in a different window.

In the Upload window I upload a file, and I want to display the name of this file in a textbox, which in turn is in a gridview on the Default page.

I think I want an asyncronous process that won't cause the Default page to refresh, but I don't know how to do this.

1

There are 1 answers

0
Krzysztof Kaźmierczak On BEST ANSWER

I created a very simple example for you. Here is the code of the first page (your Default.aspx let's say):

<html>
<head>
<script>
function ow() {
window.open('w2.html');
}
function update(updatestr) {
document.getElementById('update').innerHTML = updatestr;
}
</script>
</head>
<body>
<a href="#" onclick="ow()">open window</a>
<div id="update"></div>
</body>
</html>

This page contains a link, which opens a new window (this will be your Upload.aspx page). It also contains a simple function called update, which puts a parameter value as a div html content.

This is code of a second page (your Upload.aspx like):

<html>
<head>
<script>
function update() {
window.opener.update(document.getElementById('txt').value);
}
</script>
</head>
<body>
<input type="text" id="txt" />
<input type="button" value="Update" onclick="update()"/>
</body>
</html>

This page contains a textbox and a button. After a button click, the content of the textbox will appear in a div on the first page. You can do something similar in your case.

I've put a working demo for you.