Doubt new window

  • Thread starter Thread starter Paulo
  • Start date Start date
P

Paulo

Hi, when I click a Search button, must open a new window wich will list all
the customers on a grid, and the user can search, etc, but when the user
choose the customer, the window must be closed and returned to the original
window with the customer ID selected by the user...

How can I do that? any examples? Im using VS 2005 C# .net 2.0...

Thanks
 
Hi Paulo,
you have to use javascript. On the search button use something like
OnClientClick="javascript:OpenMyWindow(); return false;"

Now you have to define two javascript functions OpenMyWindow and UpdateValue
function.
function OpenMyWindow() {
window.open("~/Customers.aspx", other params to set up your new window);
}

function UpdateValue(returnCustomer) {
var customerTextBox = document.getElementById('customerTextBox');
customerTextBox.Value = returnCustomer; // updates value in some html
textbox

// you will probably have to refresh value here
if (document.createEvent) {
var onchangeEvent = document.createEvent('HTMLEvents');
onchangeEvent.initEvent('change', true, true);
customerTextBox.dispatchEvent(onchangeEvent);
}
else {
customerTextBox.fireEvent('onchange');
}
}

Customers.aspx will handle your grid with customers. You also need to
implement return mechanism on this page. Say for example if user select row
in grid it will return customer name back to previous window. You again need
to use javascript:

function Done(returnValue) {
window.opener.UpdateValue(returnValue); // calls UpdateValue defined in
previous window
window.close();
}

I don't say it will work exactly as I have described but at least it gives
you an idea.

Regards,
Ladislav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Doubt passing values 3
Doubt template 1
GridView and FormView 1
Doubt creating a class/function? 5
Doubt BoundField 5
GridView + JS? 1
Strange doubt javascript:confirm 5
Is possible to be done? 2

Back
Top