Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. i want call a javascript from serverside after a asynchronous post back

i want call a javascript from serverside after a asynchronous post back

Scheduled Pinned Locked Moved Web Development
questioncsharpjavascriptasp-netsysadmin
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snehasish
    wrote on last edited by
    #1

    hi; i want call a javascript from serverside after a asynchronous post back. my fragment code is like this........

    	    function displayWindow()
    	    {
    	       alert("hi,welcome to asp.net world");
    	    }
    

    ........................
    .......................

    ................
    .................
    ..................
    ..................

    in server side i have write the code..

    protected void cmdUpdate_Click(object sender, EventArgs e)
    {
    ........
    Page.RegisterStartupScript("MyScript",
    "" +
    "displayWindow();");
    .....
    }

    but when i click it can not call javascript due to asynchronous post back. but i need to call javascript then. how can i call this javascript from server side? please help me.. :(

    A R 2 Replies Last reply
    0
    • S snehasish

      hi; i want call a javascript from serverside after a asynchronous post back. my fragment code is like this........

      	    function displayWindow()
      	    {
      	       alert("hi,welcome to asp.net world");
      	    }
      

      ........................
      .......................

      ................
      .................
      ..................
      ..................

      in server side i have write the code..

      protected void cmdUpdate_Click(object sender, EventArgs e)
      {
      ........
      Page.RegisterStartupScript("MyScript",
      "" +
      "displayWindow();");
      .....
      }

      but when i click it can not call javascript due to asynchronous post back. but i need to call javascript then. how can i call this javascript from server side? please help me.. :(

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      Javascript is client side, so you cannot call it from ther server side code

      Bob Ashfield Consultants Ltd

      S 1 Reply Last reply
      0
      • A Ashfield

        Javascript is client side, so you cannot call it from ther server side code

        Bob Ashfield Consultants Ltd

        S Offline
        S Offline
        snehasish
        wrote on last edited by
        #3

        hi Bob, Thanks for reply.You told me that as javascript is in client side,i canot call them from server side.But i have called a client side javascript from serverside previously in synchronous postback by using Page.RegisterStartupScript() method. Wating for reply. Snehasish

        A 1 Reply Last reply
        0
        • S snehasish

          hi Bob, Thanks for reply.You told me that as javascript is in client side,i canot call them from server side.But i have called a client side javascript from serverside previously in synchronous postback by using Page.RegisterStartupScript() method. Wating for reply. Snehasish

          A Offline
          A Offline
          Ashfield
          wrote on last edited by
          #4

          Sorry, I misread your post, \I thoght it said excute the javascript on the server. Must read more carefully :-O

          Bob Ashfield Consultants Ltd

          1 Reply Last reply
          0
          • S snehasish

            hi; i want call a javascript from serverside after a asynchronous post back. my fragment code is like this........

            	    function displayWindow()
            	    {
            	       alert("hi,welcome to asp.net world");
            	    }
            

            ........................
            .......................

            ................
            .................
            ..................
            ..................

            in server side i have write the code..

            protected void cmdUpdate_Click(object sender, EventArgs e)
            {
            ........
            Page.RegisterStartupScript("MyScript",
            "" +
            "displayWindow();");
            .....
            }

            but when i click it can not call javascript due to asynchronous post back. but i need to call javascript then. how can i call this javascript from server side? please help me.. :(

            R Offline
            R Offline
            Rajdev Ramasamy
            wrote on last edited by
            #5

            Hi, This can be accomplished by using BeginRequest and EndRequest methods of PageRequestManager during asyncpostback. Sample:

            <script language="javascript" type="text/javascript">
            <!--
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_initializeRequest(InitializeRequest);
            prm.add_endRequest(EndRequest);
            var postBackElement;
            function InitializeRequest(sender, args) {
            postBackElement = args.get_postBackElement();
            }
            function EndRequest(sender, args) {
            if (postBackElement.id == 'cmdUpdate') {
            displayWindow();
            }
            }

            // -->
            </script>

            Hope this would be useful. Please revert back on any queries. Thanks, Rajdev KR

            S 1 Reply Last reply
            0
            • R Rajdev Ramasamy

              Hi, This can be accomplished by using BeginRequest and EndRequest methods of PageRequestManager during asyncpostback. Sample:

              <script language="javascript" type="text/javascript">
              <!--
              var prm = Sys.WebForms.PageRequestManager.getInstance();
              prm.add_initializeRequest(InitializeRequest);
              prm.add_endRequest(EndRequest);
              var postBackElement;
              function InitializeRequest(sender, args) {
              postBackElement = args.get_postBackElement();
              }
              function EndRequest(sender, args) {
              if (postBackElement.id == 'cmdUpdate') {
              displayWindow();
              }
              }

              // -->
              </script>

              Hope this would be useful. Please revert back on any queries. Thanks, Rajdev KR

              S Offline
              S Offline
              snehasish
              wrote on last edited by
              #6

              hi Rajdev; awesome,very nice code,many thanks. :)   :)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups