accessing a registered startup script in c# code

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

    accessing a registered startup script in c# code

    I have this code in one of my methods:
    ClientScript.Re gisterStartupSc ript(GetType(), "AddNews",

    "alert('Sor ry! For some reason, the news article couldn't be added. Try
    again later...');", true);


    After it is registered, I will now need to make this script run. How do you
    do that?



  • Mark Rae [MVP]

    #2
    Re: accessing a registered startup script in c# code

    "Andy B" <a_borka@sbcglo bal.netwrote in message
    news:OTjZr9KTIH A.5164@TK2MSFTN GP03.phx.gbl...
    >I have this code in one of my methods:
    ClientScript.Re gisterStartupSc ript(GetType(), "AddNews",
    >
    "alert('Sor ry! For some reason, the news article couldn't be added. Try
    again later...');", true);
    >
    >
    After it is registered, I will now need to make this script run. How do
    you do that?

    ??? It will run when your page loads...


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • marss

      #3
      Re: accessing a registered startup script in c# code

      On 1 Січ, 21:49, "Andy B" <a_bo...@sbcglo bal.netwrote:
      I have this code in one of my methods:
      ClientScript.Re gisterStartupSc ript(GetType(), "AddNews",
      >
      "alert('Sor ry! For some reason, the news article couldn't be added. Try
      again later...');", true);
      >

      Hi Andy

      It does not execute while page is loading because of mistake in your
      script. You can use single quotes to define a string in javascript
      only if that string does not contain single quote itself.

      Try this:
      ClientScript.Re gisterStartupSc ript(GetType(), "AddNews",
      "alert(\"So rry! For some reason, the news article couldn't be added.
      Try again later...\");", true);

      Regards,
      Mykola





      Comment

      • Mark Rae [MVP]

        #4
        Re: accessing a registered startup script in c# code

        "marss" <marss.ua@gmail .comwrote in message
        news:3e0caa86-7f8c-49d0-830a-4fcb1ce8b3d3@f3 g2000hsg.google groups.com...
        You can use single quotes to define a string in javascript
        only if that string does not contain single quote itself.
        That's not true - all you need to do is escape the single quote within the
        string, e.g.

        ClientScript.Re gisterStartupSc ript(GetType(), "AddNews", "alert('Sor ry! For
        some reason, the news article couldn\'t be added. Try again later...');",
        true);


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • marss

          #5
          Re: accessing a registered startup script in c# code

          On 2 Січ, 16:03, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
          "marss" <marss...@gmail .comwrote in message
          >
          news:3e0caa86-7f8c-49d0-830a-4fcb1ce8b3d3@f3 g2000hsg.google groups.com...
          >
          You can use single quotes to define a string in javascript
          only if that string does not contain single quote itself.
          >
          That's not true - all you need to do is escape the single quote within the
          string, e.g.
          >
          ClientScript.Re gisterStartupSc ript(GetType(), "AddNews", "alert('Sor ry! For
          some reason, the news article couldn\'t be added. Try again later...');",
          true);
          >
          --
          Mark Rae
          ASP.NET MVPhttp://www.markrae.net
          Hi Mark,

          It is true, at least in that case. Try to test the example you
          suggested and you'll see the problem.

          Regards,
          Mykola

          Comment

          • Mark Rae [MVP]

            #6
            Re: accessing a registered startup script in c# code

            "marss" <marss.ua@gmail .comwrote in message
            news:fe47f71a-cda5-4b39-ae02-9f7d7a955db0@i7 g2000prf.google groups.com...
            It is true, at least in that case. Try to test the example you
            suggested and you'll see the problem.
            Apologies for the typo...

            ClientScript.Re gisterStartupSc ript(GetType(), "AddNews", "alert('Sor ry! For
            some reason, the news article couldn\\'t be added. Try again later...');",
            true);


            --
            Mark Rae
            ASP.NET MVP


            Comment

            • marss

              #7
              Re: accessing a registered startup script in c# code

              On 2 Січ, 23:32, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
              ClientScript.Re gisterStartupSc ript(GetType(), "AddNews", "alert('Sor ry! For
              some reason, the news article couldn\\'t be added. Try again later...');",
              true);
              >
              Well, it is a variant. Quite good variant :)

              Regards,
              Mykola

              Comment

              Working...