Q: (ASP.NET JAVASCRIPT and C#) Hide result of javascript calling C# method I am trying to hide the result of a C# method which is called from my javascript code in my aspx file. When I view the page source I want to return value, presently 'HI_MOM!', to not be visible.
My ASPX:
<html>
  <head>
    <title>Hide Me</title>
  </head>
  <body><div id="center"><div id="fig">
    <script type="text/javascript">
        var url = <%="'"+magic()+"'"%>;
        document.write(url);
    </script>
  </div></div></body>
</html>

My C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class TestTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public string magic()
    {
        return "HI_MOM!";
    }
}

Source Code after Running:

<html>
  <head>
    <title>Hide Me</title>
  </head>
  <body><div id="center"><div id="fig">
    <script type="text/javascript">
        var url = HI_MOM!;
        document.write(url.toString);
    </script>
  </div></div></body>
</html>

Basically, I want to make it so that when I view the source code for the page the line "var url = HI_MOM!;" is not visible to the user or is masked in some way.
EDIT: 
ANSWER: (with thanks to @Shadow Wizard for pointing me in the right direction)
In TestTest.aspx:
<script type="text/javascript" src="./jquery.js"></script>

.
.
.
 jQuery.ajax({
    type: 'POST',
    url: 'TestTest.aspx/magic',
    cache: false,
    data: '{}',
    contentType: 'application/json; charset=utf-8',
    dataType: 'text',
    success: function (msg) {
        var result = eval('(' + msg + ')');
        result = eval('('+result["d"]+')');

        //do something with your string =]
    }
 });

In TestTest.aspx.cs:
[WebMethod]
    public static string magic()
    {
        return "HI_MOM!";
    }


A: var url = <%= "'" + magic() + "'"%>;


A: Everything you want to run as javascript will be viewable to the user. You could make it look less obvious what it is doing or even go as far as encrypting it, but it's still all there in the browser. 
The only way to truly hide this would be to do it all server side.

A: You will have to use AJAX for this.
Using jQuery is one option, with this you can turn magic to be Page Method then consume it.
