writing code on the cancel button of a pop-up window

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have code which checks whether a datagrid is empty and if it is it shows a
panel on my page. If its not empty then Im using the server.transfer to go to
another page so as im able to use the items in an array list. My problem is
that I also have had to incorporate some Javascript to see whether the user
is ok with moving forward. Everything is fine and works apart from when the
user clicks cancel on the pop-up Internet Explorer window it stills lets them
move on. I need to be able to introduce something which keeps the user on the
same page if they click cancel.

Has anyone any idea how I can achieve this or if this is possible in my
circumstances.

private void checkdgSearchResults()
{
if(this.DataGrid1.Items.Count == 0)
{
this.pnlSearchAddresses.Visible = true;
}

else
{

ArrayList addresses;
addresses = (ArrayList) ViewState["Addresses"];
Context.Items["TransferAddresses"] = addresses;
string surname = this.Textbox7.Text;
Context.Items["test"] = surname;
Response.Write("<script language='JavaScript'>(window.confirm('The
search fee will now be deducted for the criteria entered. Do you wish to
continue?'));</script>");
Server.Transfer("ArrayListItemsDisplayed.aspx");

}
}
 
hi stephen,

I have given a sample code for doin the exact thing in a post few minutes
back,
see ur post "Client side and server side code"
on how to use the confirm message box and how to trap ok and cancel events.
U need to use the add attributes for the button to render the javascript to
the page.
Using response.write to render the script might not help you in getting back
the "OK" click event.

hope this helps,
Kannan.V [MCAD.net]
 
this doesn't really solve my problem you see as the server.transfer kicks in
any way as this is the next line of code. I need to be able to stop this some
how, but don't have a clue how to work round my percise problem. There has to
be away but I can't see it. Basically I need to transfer the page using
server.transfer if the user clicks ok and if they click cancel I need the
page to cancel the navigation and remain where it is. Have you any ideas.
With the code I have given in this post do you know what I can do??

Kannan.V said:
hi stephen,

I have given a sample code for doin the exact thing in a post few minutes
back,
see ur post "Client side and server side code"
on how to use the confirm message box and how to trap ok and cancel events.
U need to use the add attributes for the button to render the javascript to
the page.
Using response.write to render the script might not help you in getting back
the "OK" click event.

hope this helps,
Kannan.V [MCAD.net]
Stephen said:
I have code which checks whether a datagrid is empty and if it is it shows a
panel on my page. If its not empty then Im using the server.transfer to go to
another page so as im able to use the items in an array list. My problem is
that I also have had to incorporate some Javascript to see whether the user
is ok with moving forward. Everything is fine and works apart from when the
user clicks cancel on the pop-up Internet Explorer window it stills lets them
move on. I need to be able to introduce something which keeps the user on the
same page if they click cancel.

Has anyone any idea how I can achieve this or if this is possible in my
circumstances.

private void checkdgSearchResults()
{
if(this.DataGrid1.Items.Count == 0)
{
this.pnlSearchAddresses.Visible = true;
}

else
{

ArrayList addresses;
addresses = (ArrayList) ViewState["Addresses"];
Context.Items["TransferAddresses"] = addresses;
string surname = this.Textbox7.Text;
Context.Items["test"] = surname;
Response.Write("<script language='JavaScript'>(window.confirm('The
search fee will now be deducted for the criteria entered. Do you wish to
continue?'));</script>");
Server.Transfer("ArrayListItemsDisplayed.aspx");

}
}
 
Back
Top