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. ASP.NET
  4. as you see,please tell me why

as you see,please tell me why

Scheduled Pinned Locked Moved ASP.NET
3 Posts 2 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.
  • R Offline
    R Offline
    Robert_Pan
    wrote on last edited by
    #1

    a.aspx

    function btnLogin_onclick() {
    var NumRandom = document.getElementById("lblRandom").value;
    if (compare()) {
    var str = '<%=WebEncrypt("' + NumRandom + '")%>';
    document.write(str);
    }

    a.aspx.cs

    public string WebEncrypt(string Text)
    {
    //return DESEncrypt.Encrypt(Text); //DES
    return Text;
    }

    :sigh: it returns '+NumRandom+',Whyyyyyyyyyyyyy.....

    A 1 Reply Last reply
    0
    • R Robert_Pan

      a.aspx

      function btnLogin_onclick() {
      var NumRandom = document.getElementById("lblRandom").value;
      if (compare()) {
      var str = '<%=WebEncrypt("' + NumRandom + '")%>';
      document.write(str);
      }

      a.aspx.cs

      public string WebEncrypt(string Text)
      {
      //return DESEncrypt.Encrypt(Text); //DES
      return Text;
      }

      :sigh: it returns '+NumRandom+',Whyyyyyyyyyyyyy.....

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Yaa... I think you dont know the basics of Web programming right. Let me explain you. In case of Web Applications, if you write server tag like <% %> it will get replaced in response. Therefore, anything in the server tag is evaluated when the actual page is rendered. But as javascript runs in the browser, it will run after all the page processing is done and the response in the browser. You cant call a server method this way using server tag. You need to use AJAX to call server methods. You might use ICallbackEventHandler or PageMethods or your custom AJAX to do this job. But seriously, you cant pass value of javascript variable this way.. :cool:

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Windows7 API Code Pack
      Simplify Code Using NDepend
      Basics of Bing Search API using .NET

      R 1 Reply Last reply
      0
      • A Abhishek Sur

        Yaa... I think you dont know the basics of Web programming right. Let me explain you. In case of Web Applications, if you write server tag like <% %> it will get replaced in response. Therefore, anything in the server tag is evaluated when the actual page is rendered. But as javascript runs in the browser, it will run after all the page processing is done and the response in the browser. You cant call a server method this way using server tag. You need to use AJAX to call server methods. You might use ICallbackEventHandler or PageMethods or your custom AJAX to do this job. But seriously, you cant pass value of javascript variable this way.. :cool:

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Windows7 API Code Pack
        Simplify Code Using NDepend
        Basics of Bing Search API using .NET

        R Offline
        R Offline
        Robert_Pan
        wrote on last edited by
        #3

        :laugh: 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