Client-side script embedded in code behind

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");

}
}
 
G

Guest

no sorry this isn;t what im looking for as my problem is that im using the
server.transfer to take accross an arraylist as my first post outlines. You
see I want the server.transfer to kick in if the user clicks yes, however if
the user clicks no I need to be able to keep the user on the same page. Can
you help.

Cor Ligthert said:
Stephen,

Here a sample in VBNet language
You need of course to reference to your function in the page normally

\\\
Dim str As String
str = "<script language=javascript> {window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///
A full description
http://msdn.microsoft.com/library/d.../en-us/dnaspp/html/aspnet-usingjavascript.asp

I hope this helps a little bit?

Cor

Cor

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");

}
}
 
C

Cor Ligthert

Stephen,

You are mixing up now ServerSide and ClientSide, when you use a panel that
you make visible and hide in the same wat as a PopupWindow, the user does
not notice that you are doing things and are busy on the serverside.

In my opinion is that much easier to handle.

Cor

Stephen said:
no sorry this isn;t what im looking for as my problem is that im using the
server.transfer to take accross an arraylist as my first post outlines.
You
see I want the server.transfer to kick in if the user clicks yes, however
if
the user clicks no I need to be able to keep the user on the same page.
Can
you help.

Cor Ligthert said:
Stephen,

Here a sample in VBNet language
You need of course to reference to your function in the page normally

\\\
Dim str As String
str = "<script language=javascript>
{window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///
A full description
http://msdn.microsoft.com/library/d.../en-us/dnaspp/html/aspnet-usingjavascript.asp

I hope this helps a little bit?

Cor

Cor

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");

}
}
 
G

Guest

ok forgetting all of that ive been looking around and on different forums and
i'm coming to the conclusion that what I want to do isn't possible at present.

Basically i need the onclick of a button to bring up a Internet Explorer
MessageBox which asks the user if they want to continue. If the user clicks
yes I need the Server.Transfer to be used to direct the user to a different
page. If the user click cancel I need the user to simply return to the page
which they are already on.

I didn't think it would be difficult and its not when your simply directing
the user from page to page but when you need to user the server.transfer then
im snookered!! Any remaining thoughts about how I can achieve that,
forgetting the panels and validation etc

Cor Ligthert said:
Stephen,

You are mixing up now ServerSide and ClientSide, when you use a panel that
you make visible and hide in the same wat as a PopupWindow, the user does
not notice that you are doing things and are busy on the serverside.

In my opinion is that much easier to handle.

Cor

Stephen said:
no sorry this isn;t what im looking for as my problem is that im using the
server.transfer to take accross an arraylist as my first post outlines.
You
see I want the server.transfer to kick in if the user clicks yes, however
if
the user clicks no I need to be able to keep the user on the same page.
Can
you help.

Cor Ligthert said:
Stephen,

Here a sample in VBNet language
You need of course to reference to your function in the page normally

\\\
Dim str As String
str = "<script language=javascript>
{window.open('http://www.google.com');}
</script>"
RegisterStartupScript("Startup", str)
///
A full description
http://msdn.microsoft.com/library/d.../en-us/dnaspp/html/aspnet-usingjavascript.asp

I hope this helps a little bit?

Cor

Cor

"Stephen" <[email protected]> schreef in bericht
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");

}
}
 

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

Top