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 6583247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:23:02+00:00 2026-05-25T16:23:02+00:00

I have a page defined as: <%@ Page Language=C# %> <html> <head> <title>Untitled 1</title>

  • 0

I have a page defined as:

<%@ Page Language="C#" %>
<html>

<head>
<title>Untitled 1</title>
<script type="text/c#">
    public void WriteHello()
    {
        Response.Write("HELLO EVERYBODY");
    }
</script>
</head>
<body>
    <div>
        <% WriteHello(); %>
    </div>
</body>
</html>

But this throws the compilation error of:

The name ‘WriteHello’ does not exist in the current context

If I move the C# code to a seperate file, and link to it, it works as expected. But for this I need to keep it in the same file. Can you not call inline methods like this? Or am I missing something very obvious?

  • 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-25T16:23:03+00:00Added an answer on May 25, 2026 at 4:23 pm

    The script tag you have coded is a client side script – it will try to execute on the browser. The code that tries to use it runs on the server.

    You need to change the script to be server side script:

    <script runat="server">
    

    You can write this as:

    <%
        public void WriteHello()
        {
            Response.Write("HELLO EVERYBODY");
        }
    %>
    

    Which is the syntax you used elsewhere already.

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

Sidebar

Related Questions

I have an aspx page defined as follows: <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server> <title></title> <script
I have a view that is strongly typed: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage<MPKwithMVC.Models.SmartFormViewModel>
I have a custom XML schema defined for page display that puts elements on
I have a web page with swf file defined this way <object width=600 height=400
I have a master page with tabs. The tabs are defined by the following
I have defined a function in which i want to open a page on
I have a CSS stylesheet defined in the Master Page of my project. On
I have a GridView control on my page that I have defined a number
I have a path defined: when /the admin home\s?page/ /admin/ I have scenario that
is it possible to have links on the welcome page which point to defined

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.