I have a Main page that contains a listBox.
When a user selects a profile form the list box, this opens up a child window called pWindow
.
This window as the option to delete the current profile via a hyperlink button that opens up a another confirmation window called dprofile
.
My question being is it possible that once a user has confirmed to delete the current profile they are in, and confirmed it in the button click on dProfile
, how can I update the listBox in the first Main page so that the list no longer contains the deleted profile (which it is not doing at present.
In the dProfile
window I have created an event -
public event EventHandler SubmitClicked;
Where in the OK button click I have-
private void OKButton_Click(object sender, RoutedEventArgs e)
{
if (SubmitClicked != null)
{
SubmitClicked(this, new EventArgs());
}
}
So on the Main page I have added-
private void deleteProfile_SubmitClicked(object sender, EventArgs e)
{
WebService.Service1SoapClient client = new WebService.Service1SoapClient();
listBox1.Items.Clear();
client.profileListCompleted += new EventHandler<profileListCompletedEventArgs>(client_profileListCompleted);
client.profileListAsync(ID);
}
I thought this may have updated the listBox as it was confirmed in the dProfile
form however when the form closes, the listBox stays the same and I have to manually refresh the webpage to see the update. How can I do this?
If I understood it correctly then you have three pages. Main, pWindow and dProfile. Earlier you were trying to close pWindwow from dProfile and that was working properly. Now you want to refresh the listBox1 on Main Page.
To achieve that you may follow a similar strategy. You are probably opening pWindow from Main page with something on the following line
Now you may define a new event in pWindow class.
Then in your event handler for deleteProfile_SubmitClicked you may raise the event to refresh listbox1, something on the following line:
Then in your main page register the event against pWin object, which you defined earlier.
Then define the event in Main page.
This should refresh the listbox. I haven't test the code or the syntax. So you may check it before implementing.
EDIT
you may define the event in dProfile as static
Then you will be able to register it in Main and pWindow against Class Name
Then implement it accordingly, in pWindow, close the window and in main refresh listbox
EDIT:
You may create instance of deleteProfile on the main page register the following in your main
this should work