Client-side script embedded in code behind

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen

    #1

    Client-side script embedded in code behind

    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 checkdgSearchRe sults()
    {
    if(this.DataGri d1.Items.Count == 0)
    {
    this.pnlSearchA ddresses.Visibl e = true;
    }

    else
    {

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

    }
    }
  • Cor Ligthert

    #2
    Re: Client-side script embedded in code behind

    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=javasc ript> {window.open('h ttp://www.google.com' );}
    </script>"
    RegisterStartup Script("Startup ", str)
    ///
    A full description
    http://msdn.microsoft.com/library/de...javascript.asp

    I hope this helps a little bit?

    Cor

    Cor

    "Stephen" <Stephen@discus sions.microsoft .com> schreef in bericht
    news:B5E6A166-4ABA-4613-AF25-1BA3698165EA@mi crosoft.com...[color=blue]
    >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 checkdgSearchRe sults()
    > {
    > if(this.DataGri d1.Items.Count == 0)
    > {
    > this.pnlSearchA ddresses.Visibl e = true;
    > }
    >
    > else
    > {
    >
    > ArrayList addresses;
    > addresses = (ArrayList) ViewState["Addresses"];
    > Context.Items["TransferAddres ses"] = addresses;
    > string surname = this.Textbox7.T ext;
    > Context.Items["test"] = surname;
    > Response.Write( "<script language='JavaS cript'>(window. confirm('The
    > search fee will now be deducted for the criteria entered. Do you wish to
    > continue?'));</script>");
    > Server.Transfer ("ArrayListItem sDisplayed.aspx ");
    >
    > }
    > }[/color]


    Comment

    • Stephen

      #3
      Re: Client-side script embedded in code behind

      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" wrote:
      [color=blue]
      > 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=javasc ript> {window.open('h ttp://www.google.com' );}
      > </script>"
      > RegisterStartup Script("Startup ", str)
      > ///
      > A full description
      > http://msdn.microsoft.com/library/de...javascript.asp
      >
      > I hope this helps a little bit?
      >
      > Cor
      >
      > Cor
      >
      > "Stephen" <Stephen@discus sions.microsoft .com> schreef in bericht
      > news:B5E6A166-4ABA-4613-AF25-1BA3698165EA@mi crosoft.com...[color=green]
      > >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 checkdgSearchRe sults()
      > > {
      > > if(this.DataGri d1.Items.Count == 0)
      > > {
      > > this.pnlSearchA ddresses.Visibl e = true;
      > > }
      > >
      > > else
      > > {
      > >
      > > ArrayList addresses;
      > > addresses = (ArrayList) ViewState["Addresses"];
      > > Context.Items["TransferAddres ses"] = addresses;
      > > string surname = this.Textbox7.T ext;
      > > Context.Items["test"] = surname;
      > > Response.Write( "<script language='JavaS cript'>(window. confirm('The
      > > search fee will now be deducted for the criteria entered. Do you wish to
      > > continue?'));</script>");
      > > Server.Transfer ("ArrayListItem sDisplayed.aspx ");
      > >
      > > }
      > > }[/color]
      >
      >
      >[/color]

      Comment

      • Cor Ligthert

        #4
        Re: Client-side script embedded in code behind

        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" <Stephen@discus sions.microsoft .com>
        [color=blue]
        > 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" wrote:
        >[color=green]
        >> 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=javasc ript>
        >> {window.open('h ttp://www.google.com' );}
        >> </script>"
        >> RegisterStartup Script("Startup ", str)
        >> ///
        >> A full description
        >> http://msdn.microsoft.com/library/de...javascript.asp
        >>
        >> I hope this helps a little bit?
        >>
        >> Cor
        >>
        >> Cor
        >>
        >> "Stephen" <Stephen@discus sions.microsoft .com> schreef in bericht
        >> news:B5E6A166-4ABA-4613-AF25-1BA3698165EA@mi crosoft.com...[color=darkred]
        >> >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 checkdgSearchRe sults()
        >> > {
        >> > if(this.DataGri d1.Items.Count == 0)
        >> > {
        >> > this.pnlSearchA ddresses.Visibl e = true;
        >> > }
        >> >
        >> > else
        >> > {
        >> >
        >> > ArrayList addresses;
        >> > addresses = (ArrayList) ViewState["Addresses"];
        >> > Context.Items["TransferAddres ses"] = addresses;
        >> > string surname = this.Textbox7.T ext;
        >> > Context.Items["test"] = surname;
        >> > Response.Write( "<script language='JavaS cript'>(window. confirm('The
        >> > search fee will now be deducted for the criteria entered. Do you wish
        >> > to
        >> > continue?'));</script>");
        >> > Server.Transfer ("ArrayListItem sDisplayed.aspx ");
        >> >
        >> > }
        >> > }[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        • Stephen

          #5
          Re: Client-side script embedded in code behind

          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" wrote:
          [color=blue]
          > 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" <Stephen@discus sions.microsoft .com>
          >[color=green]
          > > 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" wrote:
          > >[color=darkred]
          > >> 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=javasc ript>
          > >> {window.open('h ttp://www.google.com' );}
          > >> </script>"
          > >> RegisterStartup Script("Startup ", str)
          > >> ///
          > >> A full description
          > >> http://msdn.microsoft.com/library/de...javascript.asp
          > >>
          > >> I hope this helps a little bit?
          > >>
          > >> Cor
          > >>
          > >> Cor
          > >>
          > >> "Stephen" <Stephen@discus sions.microsoft .com> schreef in bericht
          > >> news:B5E6A166-4ABA-4613-AF25-1BA3698165EA@mi crosoft.com...
          > >> >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 checkdgSearchRe sults()
          > >> > {
          > >> > if(this.DataGri d1.Items.Count == 0)
          > >> > {
          > >> > this.pnlSearchA ddresses.Visibl e = true;
          > >> > }
          > >> >
          > >> > else
          > >> > {
          > >> >
          > >> > ArrayList addresses;
          > >> > addresses = (ArrayList) ViewState["Addresses"];
          > >> > Context.Items["TransferAddres ses"] = addresses;
          > >> > string surname = this.Textbox7.T ext;
          > >> > Context.Items["test"] = surname;
          > >> > Response.Write( "<script language='JavaS cript'>(window. confirm('The
          > >> > search fee will now be deducted for the criteria entered. Do you wish
          > >> > to
          > >> > continue?'));</script>");
          > >> > Server.Transfer ("ArrayListItem sDisplayed.aspx ");
          > >> >
          > >> > }
          > >> > }
          > >>
          > >>
          > >>[/color][/color]
          >
          >
          >[/color]

          Comment

          Working...