Call javascript form C# problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baburk
    New Member
    • Oct 2006
    • 111

    Call javascript form C# problem

    Hi,

    When I set EnablePartialRe ndering = false it works.

    But I want EnablePartialRe ndering = true.

    How to over come this.

    Page.ClientScri pt.RegisterClie ntScriptBlock(P age.GetType(), "Move", "scrollToXY(10, 10);", true);

    Thanks in advance
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by baburk
    Hi,

    When I set EnablePartialRe ndering = false it works.

    But I want EnablePartialRe ndering = true.

    How to over come this.

    Page.ClientScri pt.RegisterClie ntScriptBlock(P age.GetType(), "Move", "scrollToXY(10, 10);", true);

    Thanks in advance

    What is the error you're getting?
    Are you having problems registering your script in the page?
    Consider using ScriptManager.R egisterClientSc riptBlock instead.....

    Could you please provide more information about your problem.

    Thanks
    -Frinny

    Comment

    • baburk
      New Member
      • Oct 2006
      • 111

      #3
      Originally posted by Frinavale
      What is the error you're getting?
      Are you having problems registering your script in the page?
      Consider using ScriptManager.R egisterClientSc riptBlock instead.....

      Could you please provide more information about your problem.

      Thanks
      -Frinny
      No I didn't get any error on registering thescript in the page.

      When I set PartialPageRend ering = false it works fine.

      But when i set it to PartialPageRend ering = true it did't call the script and didn't throw any error.

      Through breakpoint i chencked it called correctly.

      I heard that when i set PartialPageRend ering = false it renders only partial page.
      So the script didn't load in the page. So the script can't be called.

      Thanks

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by baburk
        No I didn't get any error on registering thescript in the page.

        When I set PartialPageRend ering = false it works fine.

        But when i set it to PartialPageRend ering = true it did't call the script and didn't throw any error.

        Through breakpoint i chencked it called correctly.

        I heard that when i set PartialPageRend ering = false it renders only partial page.
        So the script didn't load in the page. So the script can't be called.

        Thanks
        As I stated before, have you looked into using ScriptManager.R egisterClientSc riptBlock instead of the Page.RegisterCl ientScriptBlock ?

        JavaScript doesn't work after a partial page update has occurred. In order to get around this the ScriptManager and ScriptManagerPr oxy classes were created. These allow you to re-register your JavaScript when the partial page update occurs so that it can still be accessed by the page.

        -Frinny

        Comment

        • baburk
          New Member
          • Oct 2006
          • 111

          #5
          Hi Frinavale,

          I have put like this in C#

          ScriptManager.R egisterClientSc riptBlock(this, Page.GetType(), "Scroll", "ScrollToPositi on();", true);

          and the Script is

          <script language = "javascript " type = "text/javascript">
          function ScrollToPositio n()
          {
          window.scrollTo (10,10);
          }

          </script>

          The firefox grives an error message as ScrollToPositio n is not defined but is scrolls.

          In IE it gives an errormessage that Microsoft JScript runtime error: Object expected and it points to the script function ScrollToPositio n

          When I called the function from onClientClick it works fine on both the browsers.

          Will you tell me what the wrong in thisScriptManager.R egisterClientSc riptBlock(this, Page.GetType(), "Scroll", "ScrollToPositi on();", true);

          and also I tried like this ScriptManager.R egisterClientSc riptBlock(this, Page.GetType(), "Scroll", "ScrollToPositi on();", true);

          Thanks

          Comment

          Working...