User Message

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

    #1

    User Message

    Hi I want to pop up a little window (sort of a message
    box), so I call MessageBoxA function during postback, and
    I get "error on page" icon. What's the way to popup a new
    window? Thanks!


    public static void MessageBoxA(str ing message)
    {
    HttpContext.Cur rent.Response.W rite("<script
    language='javas cript'>");
    string writestring = "myWindow = window.open(\"\ ",
    \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
    "myWindow.docum ent.write(\"" + message + "\");" +
    "myWindow.docum ent.bgColor=\"l ightblue\";" +
    "myWindow.docum ent.close(); ";

    HttpContext.Cur rent.Response.W rite(writestrin g);
    HttpContext.Cur rent.Response.W rite("</script>");

    }
  • John Timney \(Microsoft MVP\)

    #2
    Re: User Message

    You either have to create a new browser window, or use the javascript alert
    method

    See below for some examples
    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_auth or_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_autho r_plug>
    ----------------------------------------------


    <html>
    <head>
    <script language="VB" runat="server">

    Sub Page_Load( sender as Object,e as EventArgs)

    'Form the script that is to be registered at client side.
    Dim scriptString as String = "<script language=JavaSc ript> function
    DoClick() {"
    ScriptString +=
    "window.open('h ttp://www.mvps.org',' MyWindow','widt h=500,height=50 0');}<"
    scriptString += "/"
    scriptString += "script>"

    If(Not IsClientScriptB lockRegistered( "clientScript") )
    RegisterClientS criptBlock("cli entScript", scriptString)
    End If
    End Sub
    </script>
    </head>
    <body topmargin="20" leftmargin="10" >
    <form id="myForm" runat="server">
    <input type="button" value="ClickMe" onclick="DoClic k()">
    </form>
    </body>
    </html>

    <html>
    <head>
    <script language="VB" runat="server">

    Sub button_onClick( sender as Object,e as EventArgs)
    Response.Write( "Postback as requested!!!")
    End Sub


    </script>
    </head>

    <body topmargin="20" leftmargin="10" >
    <form id="myForm" runat="server">

    <input type="button" value="OK" onserverclick=" button_onClick"
    onclick="if(!co nfirm('You wanna do the postback?')){re turn false;}"
    runat="server">


    </form>
    </body>
    </html>




    "szabelin" <szabelin@szabe lin> wrote in message
    news:03fc01c361 1b$e16a30b0$a50 1280a@phx.gbl.. .[color=blue]
    > Hi I want to pop up a little window (sort of a message
    > box), so I call MessageBoxA function during postback, and
    > I get "error on page" icon. What's the way to popup a new
    > window? Thanks!
    >
    >
    > public static void MessageBoxA(str ing message)
    > {
    > HttpContext.Cur rent.Response.W rite("<script
    > language='javas cript'>");
    > string writestring = "myWindow = window.open(\"\ ",
    > \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
    > "myWindow.docum ent.write(\"" + message + "\");" +
    > "myWindow.docum ent.bgColor=\"l ightblue\";" +
    > "myWindow.docum ent.close(); ";
    >
    > HttpContext.Cur rent.Response.W rite(writestrin g);
    > HttpContext.Cur rent.Response.W rite("</script>");
    >
    > }[/color]


    Comment

    • szabelin

      #3
      Re: User Message

      Hello John, thanks for reply. So I am going to
      RegisterClientS criptBlock - but how do I simulate a call
      to fucntion "DoClick" from your example - my popup is not
      a result of a button click, rather it depends on some
      processing I do first in response to a postback

      Thank you
      S
      [color=blue]
      >-----Original Message-----
      >You either have to create a new browser window, or use[/color]
      the javascript alert[color=blue]
      >method
      >
      >See below for some examples
      >--
      >Regards
      >
      >John Timney (Microsoft ASP.NET MVP)
      >----------------------------------------------
      ><shameless_aut hor_plug>
      >Professional .NET for Java Developers with C#
      > ISBN:1-861007-91-4
      >Professional Windows Forms
      > ISBN: 1861005547
      >Professional JSP 2nd Edition
      > ISBN: 1861004958
      >Professional JSP
      > ISBN: 1861003625
      >Beginning JSP Web Development
      > ISBN: 1861002092
      ></shameless_autho r_plug>
      >----------------------------------------------
      >
      >
      ><html>
      > <head>
      > <script language="VB" runat="server">
      >
      > Sub Page_Load( sender as Object,e as EventArgs)
      >
      > 'Form the script that is to be registered at client[/color]
      side.[color=blue]
      > Dim scriptString as String = "<script[/color]
      language=JavaSc ript> function[color=blue]
      >DoClick() {"
      > ScriptString +=
      >"window.ope n[/color]
      ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}
      <"[color=blue]
      > scriptString += "/"
      > scriptString += "script>"
      >
      > If(Not IsClientScriptB lockRegistered[/color]
      ("clientScript" ))[color=blue]
      > RegisterClientS criptBlock("cli entScript",[/color]
      scriptString)[color=blue]
      > End If
      > End Sub
      > </script>
      > </head>
      > <body topmargin="20" leftmargin="10" >
      > <form id="myForm" runat="server">
      > <input type="button" value="ClickMe"[/color]
      onclick="DoClic k()">[color=blue]
      > </form>
      > </body>
      ></html>
      >
      ><html>
      > <head>
      > <script language="VB" runat="server">
      >
      > Sub button_onClick( sender as Object,e as EventArgs)
      > Response.Write( "Postback as requested!!!")
      > End Sub
      >
      >
      > </script>
      > </head>
      >
      > <body topmargin="20" leftmargin="10" >
      > <form id="myForm" runat="server">
      >
      > <input type="button" value="OK"[/color]
      onserverclick=" button_onClick"[color=blue]
      > onclick="if(!co nfirm('You wanna do the postback?'))[/color]
      {return false;}"[color=blue]
      > runat="server">
      >
      >
      > </form>
      > </body>
      ></html>
      >
      >
      >
      >
      >"szabelin" <szabelin@szabe lin> wrote in message
      >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..[color=green]
      >> Hi I want to pop up a little window (sort of a message
      >> box), so I call MessageBoxA function during postback,[/color][/color]
      and[color=blue][color=green]
      >> I get "error on page" icon. What's the way to popup a[/color][/color]
      new[color=blue][color=green]
      >> window? Thanks!
      >>
      >>
      >> public static void MessageBoxA(str ing message)
      >> {
      >> HttpContext.Cur rent.Response.W rite("<script
      >> language='javas cript'>");
      >> string writestring = "myWindow = window.open(\"\ ",
      >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
      >> "myWindow.docum ent.write(\"" + message + "\");" +
      >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
      >> "myWindow.docum ent.close(); ";
      >>
      >> HttpContext.Cur rent.Response.W rite(writestrin g);
      >> HttpContext.Cur rent.Response.W rite("</script>");
      >>
      >> }[/color]
      >
      >
      >.
      >[/color]

      Comment

      • bruce barker

        #4
        Re: User Message

        you should avoid this approach, as pop ad blockers will prevent your window
        from appearing.


        -- bruce (sqlwork.com)

        "szabelin" <szabelin@szabe lin> wrote in message
        news:07fe01c361 27$fff65b60$a10 1280a@phx.gbl.. .[color=blue]
        > Hello John, thanks for reply. So I am going to
        > RegisterClientS criptBlock - but how do I simulate a call
        > to fucntion "DoClick" from your example - my popup is not
        > a result of a button click, rather it depends on some
        > processing I do first in response to a postback
        >
        > Thank you
        > S
        >[color=green]
        > >-----Original Message-----
        > >You either have to create a new browser window, or use[/color]
        > the javascript alert[color=green]
        > >method
        > >
        > >See below for some examples
        > >--
        > >Regards
        > >
        > >John Timney (Microsoft ASP.NET MVP)
        > >----------------------------------------------
        > ><shameless_aut hor_plug>
        > >Professional .NET for Java Developers with C#
        > > ISBN:1-861007-91-4
        > >Professional Windows Forms
        > > ISBN: 1861005547
        > >Professional JSP 2nd Edition
        > > ISBN: 1861004958
        > >Professional JSP
        > > ISBN: 1861003625
        > >Beginning JSP Web Development
        > > ISBN: 1861002092
        > ></shameless_autho r_plug>
        > >----------------------------------------------
        > >
        > >
        > ><html>
        > > <head>
        > > <script language="VB" runat="server">
        > >
        > > Sub Page_Load( sender as Object,e as EventArgs)
        > >
        > > 'Form the script that is to be registered at client[/color]
        > side.[color=green]
        > > Dim scriptString as String = "<script[/color]
        > language=JavaSc ript> function[color=green]
        > >DoClick() {"
        > > ScriptString +=
        > >"window.ope n[/color]
        > ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}
        > <"[color=green]
        > > scriptString += "/"
        > > scriptString += "script>"
        > >
        > > If(Not IsClientScriptB lockRegistered[/color]
        > ("clientScript" ))[color=green]
        > > RegisterClientS criptBlock("cli entScript",[/color]
        > scriptString)[color=green]
        > > End If
        > > End Sub
        > > </script>
        > > </head>
        > > <body topmargin="20" leftmargin="10" >
        > > <form id="myForm" runat="server">
        > > <input type="button" value="ClickMe"[/color]
        > onclick="DoClic k()">[color=green]
        > > </form>
        > > </body>
        > ></html>
        > >
        > ><html>
        > > <head>
        > > <script language="VB" runat="server">
        > >
        > > Sub button_onClick( sender as Object,e as EventArgs)
        > > Response.Write( "Postback as requested!!!")
        > > End Sub
        > >
        > >
        > > </script>
        > > </head>
        > >
        > > <body topmargin="20" leftmargin="10" >
        > > <form id="myForm" runat="server">
        > >
        > > <input type="button" value="OK"[/color]
        > onserverclick=" button_onClick"[color=green]
        > > onclick="if(!co nfirm('You wanna do the postback?'))[/color]
        > {return false;}"[color=green]
        > > runat="server">
        > >
        > >
        > > </form>
        > > </body>
        > ></html>
        > >
        > >
        > >
        > >
        > >"szabelin" <szabelin@szabe lin> wrote in message
        > >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..[color=darkred]
        > >> Hi I want to pop up a little window (sort of a message
        > >> box), so I call MessageBoxA function during postback,[/color][/color]
        > and[color=green][color=darkred]
        > >> I get "error on page" icon. What's the way to popup a[/color][/color]
        > new[color=green][color=darkred]
        > >> window? Thanks!
        > >>
        > >>
        > >> public static void MessageBoxA(str ing message)
        > >> {
        > >> HttpContext.Cur rent.Response.W rite("<script
        > >> language='javas cript'>");
        > >> string writestring = "myWindow = window.open(\"\ ",
        > >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
        > >> "myWindow.docum ent.write(\"" + message + "\");" +
        > >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
        > >> "myWindow.docum ent.close(); ";
        > >>
        > >> HttpContext.Cur rent.Response.W rite(writestrin g);
        > >> HttpContext.Cur rent.Response.W rite("</script>");
        > >>
        > >> }[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        • John Timney \(Microsoft MVP\)

          #5
          Re: User Message

          They may well do that..mine certainly does, but they dont tend to stop
          Javacript alerts easily and there are few options for popping to the screen.

          All the button click example does is call a local (client) javascript
          function, so you could call this in HTML body onload event, or wherever you
          choose. You will still need to send the script as part of your page
          response and call it.



          --
          Regards

          John Timney (Microsoft ASP.NET MVP)
          ----------------------------------------------
          <shameless_auth or_plug>
          Professional .NET for Java Developers with C#
          ISBN:1-861007-91-4
          Professional Windows Forms
          ISBN: 1861005547
          Professional JSP 2nd Edition
          ISBN: 1861004958
          Professional JSP
          ISBN: 1861003625
          Beginning JSP Web Development
          ISBN: 1861002092
          </shameless_autho r_plug>
          ----------------------------------------------

          "bruce barker" <nospam_brubar@ safeco.com> wrote in message
          news:eQqAOHTYDH A.1580@tk2msftn gp13.phx.gbl...[color=blue]
          > you should avoid this approach, as pop ad blockers will prevent your[/color]
          window[color=blue]
          > from appearing.
          >
          >
          > -- bruce (sqlwork.com)
          >
          > "szabelin" <szabelin@szabe lin> wrote in message
          > news:07fe01c361 27$fff65b60$a10 1280a@phx.gbl.. .[color=green]
          > > Hello John, thanks for reply. So I am going to
          > > RegisterClientS criptBlock - but how do I simulate a call
          > > to fucntion "DoClick" from your example - my popup is not
          > > a result of a button click, rather it depends on some
          > > processing I do first in response to a postback
          > >
          > > Thank you
          > > S
          > >[color=darkred]
          > > >-----Original Message-----
          > > >You either have to create a new browser window, or use[/color]
          > > the javascript alert[color=darkred]
          > > >method
          > > >
          > > >See below for some examples
          > > >--
          > > >Regards
          > > >
          > > >John Timney (Microsoft ASP.NET MVP)
          > > >----------------------------------------------
          > > ><shameless_aut hor_plug>
          > > >Professional .NET for Java Developers with C#
          > > > ISBN:1-861007-91-4
          > > >Professional Windows Forms
          > > > ISBN: 1861005547
          > > >Professional JSP 2nd Edition
          > > > ISBN: 1861004958
          > > >Professional JSP
          > > > ISBN: 1861003625
          > > >Beginning JSP Web Development
          > > > ISBN: 1861002092
          > > ></shameless_autho r_plug>
          > > >----------------------------------------------
          > > >
          > > >
          > > ><html>
          > > > <head>
          > > > <script language="VB" runat="server">
          > > >
          > > > Sub Page_Load( sender as Object,e as EventArgs)
          > > >
          > > > 'Form the script that is to be registered at client[/color]
          > > side.[color=darkred]
          > > > Dim scriptString as String = "<script[/color]
          > > language=JavaSc ript> function[color=darkred]
          > > >DoClick() {"
          > > > ScriptString +=
          > > >"window.ope n[/color]
          > > ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}
          > > <"[color=darkred]
          > > > scriptString += "/"
          > > > scriptString += "script>"
          > > >
          > > > If(Not IsClientScriptB lockRegistered[/color]
          > > ("clientScript" ))[color=darkred]
          > > > RegisterClientS criptBlock("cli entScript",[/color]
          > > scriptString)[color=darkred]
          > > > End If
          > > > End Sub
          > > > </script>
          > > > </head>
          > > > <body topmargin="20" leftmargin="10" >
          > > > <form id="myForm" runat="server">
          > > > <input type="button" value="ClickMe"[/color]
          > > onclick="DoClic k()">[color=darkred]
          > > > </form>
          > > > </body>
          > > ></html>
          > > >
          > > ><html>
          > > > <head>
          > > > <script language="VB" runat="server">
          > > >
          > > > Sub button_onClick( sender as Object,e as EventArgs)
          > > > Response.Write( "Postback as requested!!!")
          > > > End Sub
          > > >
          > > >
          > > > </script>
          > > > </head>
          > > >
          > > > <body topmargin="20" leftmargin="10" >
          > > > <form id="myForm" runat="server">
          > > >
          > > > <input type="button" value="OK"[/color]
          > > onserverclick=" button_onClick"[color=darkred]
          > > > onclick="if(!co nfirm('You wanna do the postback?'))[/color]
          > > {return false;}"[color=darkred]
          > > > runat="server">
          > > >
          > > >
          > > > </form>
          > > > </body>
          > > ></html>
          > > >
          > > >
          > > >
          > > >
          > > >"szabelin" <szabelin@szabe lin> wrote in message
          > > >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..
          > > >> Hi I want to pop up a little window (sort of a message
          > > >> box), so I call MessageBoxA function during postback,[/color]
          > > and[color=darkred]
          > > >> I get "error on page" icon. What's the way to popup a[/color]
          > > new[color=darkred]
          > > >> window? Thanks!
          > > >>
          > > >>
          > > >> public static void MessageBoxA(str ing message)
          > > >> {
          > > >> HttpContext.Cur rent.Response.W rite("<script
          > > >> language='javas cript'>");
          > > >> string writestring = "myWindow = window.open(\"\ ",
          > > >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
          > > >> "myWindow.docum ent.write(\"" + message + "\");" +
          > > >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
          > > >> "myWindow.docum ent.close(); ";
          > > >>
          > > >> HttpContext.Cur rent.Response.W rite(writestrin g);
          > > >> HttpContext.Cur rent.Response.W rite("</script>");
          > > >>
          > > >> }
          > > >
          > > >
          > > >.
          > > >[/color][/color]
          >
          >[/color]


          Comment

          • szabelin

            #6
            Re: User Message


            I am sorry - again - how do you call a popup (javascript
            fuction) from the C# code in asp.net application. I got
            the registration part. Thanks John.

            [color=blue]
            >-----Original Message-----
            >They may well do that..mine certainly does, but they dont[/color]
            tend to stop[color=blue]
            >Javacript alerts easily and there are few options for[/color]
            popping to the screen.[color=blue]
            >
            >All the button click example does is call a local[/color]
            (client) javascript[color=blue]
            >function, so you could call this in HTML body onload[/color]
            event, or wherever you[color=blue]
            >choose. You will still need to send the script as part[/color]
            of your page[color=blue]
            >response and call it.
            >
            >
            >
            >--
            >Regards
            >
            >John Timney (Microsoft ASP.NET MVP)
            >----------------------------------------------
            ><shameless_aut hor_plug>
            >Professional .NET for Java Developers with C#
            > ISBN:1-861007-91-4
            >Professional Windows Forms
            > ISBN: 1861005547
            >Professional JSP 2nd Edition
            > ISBN: 1861004958
            >Professional JSP
            > ISBN: 1861003625
            >Beginning JSP Web Development
            > ISBN: 1861002092
            ></shameless_autho r_plug>
            >----------------------------------------------
            >
            >"bruce barker" <nospam_brubar@ safeco.com> wrote in message
            >news:eQqAOHTYD HA.1580@tk2msft ngp13.phx.gbl.. .[color=green]
            >> you should avoid this approach, as pop ad blockers will[/color][/color]
            prevent your[color=blue]
            >window[color=green]
            >> from appearing.
            >>
            >>
            >> -- bruce (sqlwork.com)
            >>
            >> "szabelin" <szabelin@szabe lin> wrote in message
            >> news:07fe01c361 27$fff65b60$a10 1280a@phx.gbl.. .[color=darkred]
            >> > Hello John, thanks for reply. So I am going to
            >> > RegisterClientS criptBlock - but how do I simulate a[/color][/color][/color]
            call[color=blue][color=green][color=darkred]
            >> > to fucntion "DoClick" from your example - my popup is[/color][/color][/color]
            not[color=blue][color=green][color=darkred]
            >> > a result of a button click, rather it depends on some
            >> > processing I do first in response to a postback
            >> >
            >> > Thank you
            >> > S
            >> >
            >> > >-----Original Message-----
            >> > >You either have to create a new browser window, or[/color][/color][/color]
            use[color=blue][color=green][color=darkred]
            >> > the javascript alert
            >> > >method
            >> > >
            >> > >See below for some examples
            >> > >--
            >> > >Regards
            >> > >
            >> > >John Timney (Microsoft ASP.NET MVP)
            >> > >----------------------------------------------
            >> > ><shameless_aut hor_plug>
            >> > >Professional .NET for Java Developers with C#
            >> > > ISBN:1-861007-91-4
            >> > >Professional Windows Forms
            >> > > ISBN: 1861005547
            >> > >Professional JSP 2nd Edition
            >> > > ISBN: 1861004958
            >> > >Professional JSP
            >> > > ISBN: 1861003625
            >> > >Beginning JSP Web Development
            >> > > ISBN: 1861002092
            >> > ></shameless_autho r_plug>
            >> > >----------------------------------------------
            >> > >
            >> > >
            >> > ><html>
            >> > > <head>
            >> > > <script language="VB" runat="server">
            >> > >
            >> > > Sub Page_Load( sender as Object,e as EventArgs)
            >> > >
            >> > > 'Form the script that is to be registered at[/color][/color][/color]
            client[color=blue][color=green][color=darkred]
            >> > side.
            >> > > Dim scriptString as String = "<script
            >> > language=JavaSc ript> function
            >> > >DoClick() {"
            >> > > ScriptString +=
            >> > >"window.ope n
            >> >[/color][/color][/color]
            ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}[color=blue][color=green][color=darkred]
            >> > <"
            >> > > scriptString += "/"
            >> > > scriptString += "script>"
            >> > >
            >> > > If(Not IsClientScriptB lockRegistered
            >> > ("clientScript" ))
            >> > > RegisterClientS criptBlock("cli entScript",
            >> > scriptString)
            >> > > End If
            >> > > End Sub
            >> > > </script>
            >> > > </head>
            >> > > <body topmargin="20" leftmargin="10" >
            >> > > <form id="myForm" runat="server">
            >> > > <input type="button" value="ClickMe"
            >> > onclick="DoClic k()">
            >> > > </form>
            >> > > </body>
            >> > ></html>
            >> > >
            >> > ><html>
            >> > > <head>
            >> > > <script language="VB" runat="server">
            >> > >
            >> > > Sub button_onClick( sender as Object,e as[/color][/color][/color]
            EventArgs)[color=blue][color=green][color=darkred]
            >> > > Response.Write( "Postback as requested!!!")
            >> > > End Sub
            >> > >
            >> > >
            >> > > </script>
            >> > > </head>
            >> > >
            >> > > <body topmargin="20" leftmargin="10" >
            >> > > <form id="myForm" runat="server">
            >> > >
            >> > > <input type="button" value="OK"
            >> > onserverclick=" button_onClick"
            >> > > onclick="if(!co nfirm('You wanna do the postback?'))
            >> > {return false;}"
            >> > > runat="server">
            >> > >
            >> > >
            >> > > </form>
            >> > > </body>
            >> > ></html>
            >> > >
            >> > >
            >> > >
            >> > >
            >> > >"szabelin" <szabelin@szabe lin> wrote in message
            >> > >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..
            >> > >> Hi I want to pop up a little window (sort of a[/color][/color][/color]
            message[color=blue][color=green][color=darkred]
            >> > >> box), so I call MessageBoxA function during[/color][/color][/color]
            postback,[color=blue][color=green][color=darkred]
            >> > and
            >> > >> I get "error on page" icon. What's the way to[/color][/color][/color]
            popup a[color=blue][color=green][color=darkred]
            >> > new
            >> > >> window? Thanks!
            >> > >>
            >> > >>
            >> > >> public static void MessageBoxA(str ing message)
            >> > >> {
            >> > >> HttpContext.Cur rent.Response.W rite("<script
            >> > >> language='javas cript'>");
            >> > >> string writestring = "myWindow = window.open(\"\ ",
            >> > >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
            >> > >> "myWindow.docum ent.write(\"" + message + "\");" +
            >> > >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
            >> > >> "myWindow.docum ent.close(); ";
            >> > >>
            >> > >> HttpContext.Cur rent.Response.W rite[/color][/color][/color]
            (writestring);[color=blue][color=green][color=darkred]
            >> > >> HttpContext.Cur rent.Response.W rite("</script>");
            >> > >>
            >> > >> }
            >> > >
            >> > >
            >> > >.
            >> > >[/color]
            >>
            >>[/color]
            >
            >
            >.
            >[/color]

            Comment

            • Ram

              #7
              Re: User Message

              Your javascript is not correct, try this.

              public static void MessageBoxA(str ing message)
              {
              HttpContext.Cur rent.Response.W rite("<script language='javas cript'>");
              string writestring =
              "myWindow = window.open'',' tinyWindow','to olbar,width=150 ,height=100');" +
              "myWindow.docum ent.write('" + message + "');" +
              "myWindow.docum ent.bgColor='li ghtblue';" +
              "myWindow.docum ent.close(); ";

              HttpContext.Cur rent.Response.W rite(writestrin g);
              HttpContext.Cur rent.Response.W rite("</script>");

              }

              Hope this helps.
              Ram.

              "szabelin" <szabelin@szabe lin> wrote in message news:<022901c36 1c2$2c28d8d0$a4 01280a@phx.gbl> ...[color=blue]
              > It's a corporat intranet, popups are a requirement. You
              > have the answer to my q? Thanks
              >[color=green]
              > >-----Original Message-----
              > >you should avoid this approach, as pop ad blockers will[/color]
              > prevent your window[color=green]
              > >from appearing.
              > >
              > >
              > >-- bruce (sqlwork.com)
              > >
              > >"szabelin" <szabelin@szabe lin> wrote in message
              > >news:07fe01c36 127$fff65b60$a1 01280a@phx.gbl. ..[color=darkred]
              > >> Hello John, thanks for reply. So I am going to
              > >> RegisterClientS criptBlock - but how do I simulate a call
              > >> to fucntion "DoClick" from your example - my popup is[/color][/color]
              > not[color=green][color=darkred]
              > >> a result of a button click, rather it depends on some
              > >> processing I do first in response to a postback
              > >>
              > >> Thank you
              > >> S
              > >>
              > >> >-----Original Message-----
              > >> >You either have to create a new browser window, or use[/color][/color]
              > the javascript alert[color=green][color=darkred]
              > >> >method
              > >> >
              > >> >See below for some examples
              > >> >--
              > >> >Regards
              > >> >
              > >> >John Timney (Microsoft ASP.NET MVP)
              > >> >----------------------------------------------
              > >> ><shameless_aut hor_plug>
              > >> >Professional .NET for Java Developers with C#
              > >> > ISBN:1-861007-91-4
              > >> >Professional Windows Forms
              > >> > ISBN: 1861005547
              > >> >Professional JSP 2nd Edition
              > >> > ISBN: 1861004958
              > >> >Professional JSP
              > >> > ISBN: 1861003625
              > >> >Beginning JSP Web Development
              > >> > ISBN: 1861002092
              > >> ></shameless_autho r_plug>
              > >> >----------------------------------------------
              > >> >
              > >> >
              > >> ><html>
              > >> > <head>
              > >> > <script language="VB" runat="server">
              > >> >
              > >> > Sub Page_Load( sender as Object,e as EventArgs)
              > >> >
              > >> > 'Form the script that is to be registered at[/color][/color]
              > client
              > side.[color=green][color=darkred]
              > >> > Dim scriptString as String = "<script[/color][/color]
              > language=JavaSc ript> function[color=green][color=darkred]
              > >> >DoClick() {"
              > >> > ScriptString +=
              > >> >"window.ope n
              > >>[/color][/color]
              > ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}[color=green][color=darkred]
              > >> <"
              > >> > scriptString += "/"
              > >> > scriptString += "script>"
              > >> >
              > >> > If(Not IsClientScriptB lockRegistered[/color][/color]
              > ("clientScript" ))[color=green][color=darkred]
              > >> > RegisterClientS criptBlock("cli entScript",[/color][/color]
              > scriptString)[color=green][color=darkred]
              > >> > End If
              > >> > End Sub
              > >> > </script>
              > >> > </head>
              > >> > <body topmargin="20" leftmargin="10" >
              > >> > <form id="myForm" runat="server">
              > >> > <input type="button" value="ClickMe"[/color][/color]
              > onclick="DoClic k()">[color=green][color=darkred]
              > >> > </form>
              > >> > </body>
              > >> ></html>
              > >> >
              > >> ><html>
              > >> > <head>
              > >> > <script language="VB" runat="server">
              > >> >
              > >> > Sub button_onClick( sender as Object,e as EventArgs)
              > >> > Response.Write( "Postback as requested!!!")
              > >> > End Sub
              > >> >
              > >> >
              > >> > </script>
              > >> > </head>
              > >> >
              > >> > <body topmargin="20" leftmargin="10" >
              > >> > <form id="myForm" runat="server">
              > >> >
              > >> > <input type="button" value="OK"[/color][/color]
              > onserverclick=" button_onClick"[color=green][color=darkred]
              > >> > onclick="if(!co nfirm('You wanna do the postback?'))[/color][/color]
              > {return false;}"[color=green][color=darkred]
              > >> > runat="server">
              > >> >
              > >> >
              > >> > </form>
              > >> > </body>
              > >> ></html>
              > >> >
              > >> >
              > >> >
              > >> >
              > >> >"szabelin" <szabelin@szabe lin> wrote in message
              > >> >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..
              > >> >> Hi I want to pop up a little window (sort of a[/color][/color]
              > message[color=green][color=darkred]
              > >> >> box), so I call MessageBoxA function during postback,[/color][/color]
              > and[color=green][color=darkred]
              > >> >> I get "error on page" icon. What's the way to popup a[/color][/color]
              > new[color=green][color=darkred]
              > >> >> window? Thanks!
              > >> >>
              > >> >>
              > >> >> public static void MessageBoxA(str ing message)
              > >> >> {
              > >> >> HttpContext.Cur rent.Response.W rite("<script
              > >> >> language='javas cript'>");
              > >> >> string writestring = "myWindow = window.open(\"\ ",
              > >> >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
              > >> >> "myWindow.docum ent.write(\"" + message + "\");" +
              > >> >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
              > >> >> "myWindow.docum ent.close(); ";
              > >> >>
              > >> >> HttpContext.Cur rent.Response.W rite(writestrin g);
              > >> >> HttpContext.Cur rent.Response.W rite("</script>");
              > >> >>
              > >> >> }
              > >> >
              > >> >
              > >> >.
              > >> >[/color]
              > >
              > >
              > >.
              > >[/color][/color]

              Comment

              • John Timney \(Microsoft MVP\)

                #8
                Re: User Message

                you cant call it from C# - you cant popup windows server side, which is what
                would happen if you could do this in C#. You have to do this in the browser
                as part of the response, and get the browser to do whatever it is you need
                using javascript.

                --
                Regards

                John Timney (Microsoft ASP.NET MVP)
                ----------------------------------------------
                <shameless_auth or_plug>
                Professional .NET for Java Developers with C#
                ISBN:1-861007-91-4
                Professional Windows Forms
                ISBN: 1861005547
                Professional JSP 2nd Edition
                ISBN: 1861004958
                Professional JSP
                ISBN: 1861003625
                Beginning JSP Web Development
                ISBN: 1861002092
                </shameless_autho r_plug>
                ----------------------------------------------

                "szabelin" <szabelin@szabe lin> wrote in message
                news:02a201c361 c1$fa4c1b60$a30 1280a@phx.gbl.. .[color=blue]
                >
                > I am sorry - again - how do you call a popup (javascript
                > fuction) from the C# code in asp.net application. I got
                > the registration part. Thanks John.
                >
                >[color=green]
                > >-----Original Message-----
                > >They may well do that..mine certainly does, but they dont[/color]
                > tend to stop[color=green]
                > >Javacript alerts easily and there are few options for[/color]
                > popping to the screen.[color=green]
                > >
                > >All the button click example does is call a local[/color]
                > (client) javascript[color=green]
                > >function, so you could call this in HTML body onload[/color]
                > event, or wherever you[color=green]
                > >choose. You will still need to send the script as part[/color]
                > of your page[color=green]
                > >response and call it.
                > >
                > >
                > >
                > >--
                > >Regards
                > >
                > >John Timney (Microsoft ASP.NET MVP)
                > >----------------------------------------------
                > ><shameless_aut hor_plug>
                > >Professional .NET for Java Developers with C#
                > > ISBN:1-861007-91-4
                > >Professional Windows Forms
                > > ISBN: 1861005547
                > >Professional JSP 2nd Edition
                > > ISBN: 1861004958
                > >Professional JSP
                > > ISBN: 1861003625
                > >Beginning JSP Web Development
                > > ISBN: 1861002092
                > ></shameless_autho r_plug>
                > >----------------------------------------------
                > >
                > >"bruce barker" <nospam_brubar@ safeco.com> wrote in message
                > >news:eQqAOHTYD HA.1580@tk2msft ngp13.phx.gbl.. .[color=darkred]
                > >> you should avoid this approach, as pop ad blockers will[/color][/color]
                > prevent your[color=green]
                > >window[color=darkred]
                > >> from appearing.
                > >>
                > >>
                > >> -- bruce (sqlwork.com)
                > >>
                > >> "szabelin" <szabelin@szabe lin> wrote in message
                > >> news:07fe01c361 27$fff65b60$a10 1280a@phx.gbl.. .
                > >> > Hello John, thanks for reply. So I am going to
                > >> > RegisterClientS criptBlock - but how do I simulate a[/color][/color]
                > call[color=green][color=darkred]
                > >> > to fucntion "DoClick" from your example - my popup is[/color][/color]
                > not[color=green][color=darkred]
                > >> > a result of a button click, rather it depends on some
                > >> > processing I do first in response to a postback
                > >> >
                > >> > Thank you
                > >> > S
                > >> >
                > >> > >-----Original Message-----
                > >> > >You either have to create a new browser window, or[/color][/color]
                > use[color=green][color=darkred]
                > >> > the javascript alert
                > >> > >method
                > >> > >
                > >> > >See below for some examples
                > >> > >--
                > >> > >Regards
                > >> > >
                > >> > >John Timney (Microsoft ASP.NET MVP)
                > >> > >----------------------------------------------
                > >> > ><shameless_aut hor_plug>
                > >> > >Professional .NET for Java Developers with C#
                > >> > > ISBN:1-861007-91-4
                > >> > >Professional Windows Forms
                > >> > > ISBN: 1861005547
                > >> > >Professional JSP 2nd Edition
                > >> > > ISBN: 1861004958
                > >> > >Professional JSP
                > >> > > ISBN: 1861003625
                > >> > >Beginning JSP Web Development
                > >> > > ISBN: 1861002092
                > >> > ></shameless_autho r_plug>
                > >> > >----------------------------------------------
                > >> > >
                > >> > >
                > >> > ><html>
                > >> > > <head>
                > >> > > <script language="VB" runat="server">
                > >> > >
                > >> > > Sub Page_Load( sender as Object,e as EventArgs)
                > >> > >
                > >> > > 'Form the script that is to be registered at[/color][/color]
                > client[color=green][color=darkred]
                > >> > side.
                > >> > > Dim scriptString as String = "<script
                > >> > language=JavaSc ript> function
                > >> > >DoClick() {"
                > >> > > ScriptString +=
                > >> > >"window.ope n
                > >> >[/color][/color]
                > ('http://www.mvps.org',' MyWindow','widt h=500,height=50 0');}[color=green][color=darkred]
                > >> > <"
                > >> > > scriptString += "/"
                > >> > > scriptString += "script>"
                > >> > >
                > >> > > If(Not IsClientScriptB lockRegistered
                > >> > ("clientScript" ))
                > >> > > RegisterClientS criptBlock("cli entScript",
                > >> > scriptString)
                > >> > > End If
                > >> > > End Sub
                > >> > > </script>
                > >> > > </head>
                > >> > > <body topmargin="20" leftmargin="10" >
                > >> > > <form id="myForm" runat="server">
                > >> > > <input type="button" value="ClickMe"
                > >> > onclick="DoClic k()">
                > >> > > </form>
                > >> > > </body>
                > >> > ></html>
                > >> > >
                > >> > ><html>
                > >> > > <head>
                > >> > > <script language="VB" runat="server">
                > >> > >
                > >> > > Sub button_onClick( sender as Object,e as[/color][/color]
                > EventArgs)[color=green][color=darkred]
                > >> > > Response.Write( "Postback as requested!!!")
                > >> > > End Sub
                > >> > >
                > >> > >
                > >> > > </script>
                > >> > > </head>
                > >> > >
                > >> > > <body topmargin="20" leftmargin="10" >
                > >> > > <form id="myForm" runat="server">
                > >> > >
                > >> > > <input type="button" value="OK"
                > >> > onserverclick=" button_onClick"
                > >> > > onclick="if(!co nfirm('You wanna do the postback?'))
                > >> > {return false;}"
                > >> > > runat="server">
                > >> > >
                > >> > >
                > >> > > </form>
                > >> > > </body>
                > >> > ></html>
                > >> > >
                > >> > >
                > >> > >
                > >> > >
                > >> > >"szabelin" <szabelin@szabe lin> wrote in message
                > >> > >news:03fc01c36 11b$e16a30b0$a5 01280a@phx.gbl. ..
                > >> > >> Hi I want to pop up a little window (sort of a[/color][/color]
                > message[color=green][color=darkred]
                > >> > >> box), so I call MessageBoxA function during[/color][/color]
                > postback,[color=green][color=darkred]
                > >> > and
                > >> > >> I get "error on page" icon. What's the way to[/color][/color]
                > popup a[color=green][color=darkred]
                > >> > new
                > >> > >> window? Thanks!
                > >> > >>
                > >> > >>
                > >> > >> public static void MessageBoxA(str ing message)
                > >> > >> {
                > >> > >> HttpContext.Cur rent.Response.W rite("<script
                > >> > >> language='javas cript'>");
                > >> > >> string writestring = "myWindow = window.open(\"\ ",
                > >> > >> \"tinyWindow \", 'toolbar,width= 150,height=100' );"+
                > >> > >> "myWindow.docum ent.write(\"" + message + "\");" +
                > >> > >> "myWindow.docum ent.bgColor=\"l ightblue\";" +
                > >> > >> "myWindow.docum ent.close(); ";
                > >> > >>
                > >> > >> HttpContext.Cur rent.Response.W rite[/color][/color]
                > (writestring);[color=green][color=darkred]
                > >> > >> HttpContext.Cur rent.Response.W rite("</script>");
                > >> > >>
                > >> > >> }
                > >> > >
                > >> > >
                > >> > >.
                > >> > >
                > >>
                > >>[/color]
                > >
                > >
                > >.
                > >[/color][/color]


                Comment

                Working...