Moving a string from client to server (JS -> ASPX)

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

    Moving a string from client to server (JS -> ASPX)

    In the client.js file i declare the
    following variable.

    ...
    var str = "info";
    ...

    In the corresponding ASP file called
    server.aspx.cs i declare two following
    methods.

    ...
    protected void Page_Load (
    object sender, EventArgs e){...}
    public void SomeThing () {
    ...
    String data;
    ...}
    ...

    The objective is to _SOMEHOW_ ensure
    that the value of data (in the CS file)
    is obtained from str (in the JS file).

    Note that i don't need data to be
    dynamically updated as soon as str is
    changed. It's sufficient to call the
    method SomeThing each time we pass the
    part of code where we assign the value
    "info" to str.

    Note also that i need to notify
    SomeThing about the value of str.

    Of course, the actual situation is far
    more complicated but my problem can be
    boiled down to this simple case.

    How should SomeThing be designed? How
    need i to reconstruct the lines after
    the assignment to str?

    --
    Regards
    Konrad Viltersten
    --------------------------------
    sleep - a substitute for coffee for the poor
    ambition - lack of sense to be lazy

  • Thomas 'PointedEars' Lahn

    #2
    Re: Moving a string from client to server (JS -> ASPX)

    K Viltersten wrote:
    In the client.js file i declare the
    following variable.
    >
    ...
    var str = "info";
    ...
    >
    In the corresponding ASP file called
    server.aspx.cs i declare two following
    methods.
    >
    ...
    protected void Page_Load (
    object sender, EventArgs e){...}
    public void SomeThing () {
    ...
    String data;
    ...}
    ...
    >
    The objective is to _SOMEHOW_ ensure
    that the value of data (in the CS file)
    is obtained from str (in the JS file).
    >
    Note that i don't need data to be
    dynamically updated as soon as str is
    changed. It's sufficient to call the
    method SomeThing each time we pass the
    part of code where we assign the value
    "info" to str.
    >
    Note also that i need to notify
    SomeThing about the value of str.
    It cannot be done without another HTTP request (can be XHR) because the two
    don't know about each other. If you don't know that by now, you should get
    some basic knowledge about client-server architectures first, before messing
    around with them.

    Your posting was not easily legible. The pronoun `I' is spelled with a
    capital letter always and your line length is about half of what is expected
    in Usenet (80 characters per line is the recommended maximum, 72 to 78 to
    allow for quotation without reformat). Also, cross-posting over top-level
    hierarchies is unwise as a news server may have comp.* within the Big 8
    (Usenet) but not microsoft.* which does not belong to that. So the
    discussion is going to be fragmented, and the conventions of communication
    in the TLHs may also differ.

    See also http://jibbering.com/faq/


    Followup trimmed to c.l.js

    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$8 300dec7@news.de mon.co.uk>

    Comment

    • K Viltersten

      #3
      SV: Moving a string from client to server (JS -&gt; ASPX)

      >In the client.js file i declare the
      >following variable.
      >>
      > ...
      > var str = "info";
      > ...
      >>
      >In the corresponding ASP file called
      >server.aspx. cs i declare two following
      >methods.
      >>
      > ...
      > protected void Page_Load (
      > object sender, EventArgs e){...}
      > public void SomeThing () {
      > ...
      > String data;
      > ...}
      > ...
      >>
      >The objective is to _SOMEHOW_ ensure
      >that the value of data (in the CS file)
      >is obtained from str (in the JS file).
      >>
      It cannot be done without another HTTP request (can be XHR) because the
      two
      don't know about each other. If you don't know that by now, you should
      get
      some basic knowledge about client-server architectures first, before
      messing
      around with them.

      Thanks! Trying not to be impolite i still need to point that the question
      was "how can it be done", not the opposite. Are you suggesting that
      the only (recommended) way to to request (another) page from the
      server? It would be doable in my case, of course, but i'd prefer not to
      send in the string using http://.../file.aspx?str=info.

      Perhaps i could bake it in the sender object. What do you think?

      --
      Regards
      Konrad Viltersten
      --------------------------------
      sleep - a substitute for coffee for the poor
      ambition - lack of sense to be lazy

      Comment

      • VK

        #4
        Re: Moving a string from client to server (JS -&gt; ASPX)

        On May 18, 3:42 pm, "K Viltersten" <t...@vilterste n.comwrote:
        Are you suggesting that
        the only (recommended) way to to request (another) page from the
        server?
        Welcome to HTTP ;-) It is a stateless protocol, so after the page is
        served to the client, there is _no_ connection of any kind between the
        page and the server: none.
        The only way of communication HTTP has after that is a new request
        initiated by the client: the server has no way to initiate anything.
        It would be doable in my case, of course, but i'd prefer not to
        send in the string using http://.../file.aspx?str=info.
        You don't have to do that. Use AJAX or ol'good hidden iframe to
        connect to the server and to report new src values.


        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: SV: Moving a string from client to server (JS -&gt; ASPX)

          K Viltersten wrote:
          >>In the client.js file i declare the following variable.
          >>>
          >> ...
          >> var str = "info";
          >> ...
          >>>
          >>In the corresponding ASP file called server.aspx.cs i declare two
          >>following methods.
          >>>
          >> protected void Page_Load (
          >> object sender, EventArgs e){...}
          >> public void SomeThing () {
          >> ...
          >> String data;
          >> ...}
          >> ...
          >>>
          >>The objective is to _SOMEHOW_ ensure that the value of data (in the
          >>CS file) is obtained from str (in the JS file).
          >>
          >It cannot be done without another HTTP request (can be XHR) because the
          >two don't know about each other. If you don't know that by now, you
          >should get some basic knowledge about client-server architectures
          >first, before messing around with them.
          >
          Thanks! Trying not to be impolite i still need to point that the question
          was "how can it be done", not the opposite.
          "It cannot be done without ... (can be ...) ..." reads pretty much the same
          to me.
          Are you suggesting that the only (recommended) way to to request
          (another) page from the server?
          Yes, the only way is to make a request to the server.
          It would be doable in my case, of course,
          but i'd prefer not to send in the string using
          http://.../file.aspx?str=info.
          You can also make a POST request, of course.
          Perhaps i could bake it in the sender object. What do you think?
          I don't know about a `sender' object. Must be ASP .NET-specific.

          As I said, if you don't want to submit a form, you can do an XHR, something
          along this:

          var req = new XMLHttpRequest( );
          if (req)
          {
          req.open("POST" , "file.aspx" , true);

          req.onreadystat echange = function() {
          if (req.readyState == 4)
          {
          if (req.status == 200)
          {
          // handle success
          }
          else
          {
          // handle error
          }
          }
          };

          req.send("str=" + encodeURICompon ent(str));
          }

          (See previous/other discussions about AJAX/XHR for details.)
          Probably the `sender' object you are talking about is just a
          Microsoft-provided wrapper for this.

          Nothing will work without the sufficient support for client-side scripting
          and XHR, but I guess as you are using ASP .NET which does not degrade
          gracefully by default, you already know that.


          PointedEars

          P.S.
          Signatures are to be delimited with "-- <CR><LF>", not "--<CR><LF>".
          If you had that and your software messed with it, I suggest you fix it
          or use better software. See also http://insideoe.com/
          --
          Use any version of Microsoft Frontpage to create your site.
          (This won't prevent people from viewing your source, but no one
          will want to steal it.)
          -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

          Comment

          • K Viltersten

            #6
            SV: Moving a string from client to server (JS -&gt; ASPX)

            >Are you suggesting that
            >the only (recommended) way to to request (another)
            >page from the server?
            >
            Welcome to HTTP ;-) It is a stateless protocol, so
            after the page is served to the client, there is
            _no_ connection of any kind between the page and
            the server: none.
            The only way of communication HTTP has after that is
            a new request initiated by the client: the server
            has no way to initiate anything.
            Got it. Thanks!
            >It would be doable in my case, of course, but i'd
            >prefer not to send in the string using
            > http://.../file.aspx?str=info.
            >
            You don't have to do that. Use AJAX or ol'good
            hidden iframe to connect to the server and to report
            new src values.
            Right. Got it. Thanks!

            --
            Regards
            Konrad Viltersten
            --------------------------------
            sleep - a substitute for coffee for the poor
            ambition - lack of sense to be lazy

            Comment

            • K Viltersten

              #7
              SV: SV: Moving a string from client to server (JS -&gt; ASPX)

              >>> ...
              >>> var str = "info";
              >>> ...
              >>>>
              >>>In the corresponding ASP file called server.aspx.cs i declare two
              >>>following methods.
              >>>>
              >>> protected void Page_Load (
              >>> object sender, EventArgs e){...}
              >>> public void SomeThing () {
              >>> ...
              >>> String data;
              >>> ...}
              >>> ...
              >>>>
              >>>The objective is to _SOMEHOW_ ensure that the value of data (in the
              >>>CS file) is obtained from str (in the JS file).
              >
              >Are you suggesting that the only (recommended) way to to request
              >(another) page from the server?
              >
              Yes, the only way is to make a request to the server.
              >
              >It would be doable in my case, of course,
              >but i'd prefer not to send in the string using
              >http://.../file.aspx?str=info.
              >
              You can also make a POST request, of course.
              >
              >Perhaps i could bake it in the sender object. What do you think?
              >
              I don't know about a `sender' object. Must be ASP .NET-specific.
              >
              As I said, if you don't want to submit a form, you can do an XHR,
              >something along this:
              >
              var req = new XMLHttpRequest( );
              if (req)
              {
              req.open("POST" , "file.aspx" , true);
              >
              req.onreadystat echange = function() {
              if (req.readyState == 4)
              {
              if (req.status == 200)
              {
              // handle success
              }
              else
              {
              // handle error
              }
              }
              };
              >
              req.send("str=" + encodeURICompon ent(str));
              }
              >
              (See previous/other discussions about AJAX/XHR for details.)
              Probably the `sender' object you are talking about is just a
              Microsoft-provided wrapper for this.
              >
              Nothing will work without the sufficient support for client-side scripting
              and XHR, but I guess as you are using ASP .NET which does not degrade
              gracefully by default, you already know that.
              Thanks.
              Why should i go and visit a site for Outlook Express? Are you
              recommending it? Sadly, i don't even think it's available on my
              OS, so i guess i'll have to live without it.

              --
              Regards
              Konrad Viltersten
              --------------------------------
              sleep - a substitute for coffee for the poor
              ambition - lack of sense to be lazy

              Comment

              • Gregor Kofler

                #8
                Re: SV: SV: Moving a string from client to server (JS -&gt; ASPX)

                K Viltersten meinte:
                Why should i go and visit a site for Outlook Express? Are you
                recommending it? Sadly, i don't even think it's available on my
                OS, so i guess i'll have to live without it.
                >
                --
                Regards
                Konrad Viltersten
                --------------------------------
                sleep - a substitute for coffee for the poor
                ambition - lack of sense to be lazy
                Whatever. You could still delimit your signature properly.

                Gregor



                --
                http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
                http://web.gregorkofler.com ::: meine JS-Spielwiese
                http://www.image2d.com ::: Bildagentur für den alpinen Raum

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: SV: SV: Moving a string from client to server (JS -&gt; ASPX)

                  K Viltersten wrote:Please include an attribution line, see http://jibbering.com/faq/#FAQ2_3
                  Why should i go and visit a site for Outlook Express? Are you
                  recommending it?
                  Quite the contrary. I can recommend Mozilla Thunderbird or KNode.
                  Sadly, i don't even think it's available on my
                  OS, so i guess i'll have to live without it.
                  As described on the site I pointed you to, Windows Mail that you are
                  apparently using is only the next version of Outlook Express for Windows
                  Vista, and apparently exhibits the same flaws.




                  F'up2 poster (hopefully they have fixed that bug by now)

                  PointedEars
                  --
                  Use any version of Microsoft Frontpage to create your site.
                  (This won't prevent people from viewing your source, but no one
                  will want to steal it.)
                  -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

                  Comment

                  • K Viltersten

                    #10
                    SV: SV: SV: Moving a string from client to server (JS -&gt; ASPX)

                    >>See also http://insideoe.com/
                    >
                    Please include an attribution line, see http://jibbering.com/faq/#FAQ2_3
                    >
                    >Why should i go and visit a site for Outlook Express? Are you
                    >recommending it?
                    >
                    Quite the contrary. I can recommend Mozilla Thunderbird or KNode.
                    ThunderBird has some fundamental flaws, as i've tried it but the
                    other one might be fun to test, perhaps. Thanks!
                    >Sadly, i don't even think it's available on my
                    >OS, so i guess i'll have to live without it.
                    >
                    As described on the site I pointed you to, Windows Mail that you are
                    apparently using is only the next version of Outlook Express for
                    Windows Vista, and apparently exhibits the same flaws.
                    >
                    http://insideoe.com/#the_future_of_Outlook_Express
                    Oh, new name, old issues... Yhanks for the pointers. Let's see if
                    the signature works better now.

                    --
                    Regards
                    Konrad Viltersten
                    --------------------------------
                    sleep - a substitute for coffee for the poor
                    ambition - lack of sense to be lazy

                    Comment

                    • Gregor Kofler

                      #11
                      Re: SV: SV: SV: Moving a string from client to server (JS -&gt; ASPX)

                      K Viltersten meinte:
                      ThunderBird has some fundamental flaws,
                      When compared to Windows Mail? I'm intrigued...
                      Let's see if the signature works better now.
                      It does.

                      Gregor



                      --
                      http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
                      http://web.gregorkofler.com ::: meine JS-Spielwiese
                      http://www.image2d.com ::: Bildagentur für den alpinen Raum

                      Comment

                      • K Viltersten

                        #12
                        SV: SV: SV: SV: Moving a string from client to server (JS -&gt; ASPX)

                        >ThunderBird has some fundamental flaws,
                        >
                        When compared to Windows Mail? I'm intrigued...
                        I've seen far too many casaulties of flame wars started by
                        this preludium. Since none of us two wish to be a troll, i
                        suggest we deem that as a matter of personal taste and
                        not go there. I believe every sane soul will agree... :)
                        >Let's see if the signature works better now.
                        >
                        It does.
                        I'm glad to hear that.

                        --
                        Regards
                        Konrad Viltersten
                        --------------------------------
                        sleep - a substitute for coffee for the poor
                        ambition - lack of sense to be lazy

                        Comment

                        Working...