Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6562033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:39:40+00:00 2026-05-25T13:39:40+00:00

I am trying to hide the result of a C# method which is called

  • 0

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!";
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:39:40+00:00Added an answer on May 25, 2026 at 1:39 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to hide window after its startup. I have own window-class which is
I'm trying to hide actual sub-directory from url path using mod_rewrite. The folder actual
I'm trying to hide some of my Perl program from the end user to
I'm trying to hide table view until all the data is loaded. I found
I have a problem trying to hide .php extension from the url I have
I am trying to hide a result div. Modify it. Then Show it with
Hi I'm trying to migrate my HTML/PHP/JS/XML page into one php file. I was
I am trying to hide/show/toggle a div when a button is clicked. I am
I'm trying to hide some unused journals. It seems in older versions, journals had
I am trying to hide my Add friend link if - current_user and @user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.