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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:18:09+00:00 2026-05-11T00:18:09+00:00

The following code will generate a link to the page I want to get

  • 0

The following code will generate a link to the page I want to get to.

<%= Html.ActionLink(image.Title, image.Id.ToString(), 'Image') %> 

The following code will cause the correct url to be rendered on the page.

<%= Url.Action('Index', 'Image', new { id = image.Id })%> 

But when I try to use it in javascript it fails. (with some strange error about page inheritance)

<div onclick='window.location = '<%= Url.Action('Index', 'Image', new { id = image.Id })%>''>     ... </div> 

Should the above code work? What is the correct way to generate the javascript attempted above?

Update There error I get is

Views\Home\Index.aspx.cs(9): error ASPNET: Make sure that the class defined in this code file matches the ‘inherits’ attribute, and that it extends the correct base class (e.g. Page or UserControl).

Looks like it indicates a bigger problem.

Fixed Thanks for your help, the code contained a div with runat='server'. When I removed this it runs OK. This maybe because there is no form with runat='server' but I would expect a different error for that.

As this question doesn’t seem meaningful should I delete it?

  • 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. 2026-05-11T00:18:10+00:00Added an answer on May 11, 2026 at 12:18 am

    This should work actually. ASP.NET MVC will substitute all <%= … %> or similar tags, it does not recognize whether it’s a html definition or javascript. What is the output of your view? Is the ‘strange error’ coming from Javascript or ASP.NET?

    EDIT: regarding your update: make sure your Index.aspx has the ‘Codebehind’ attribute (this is in Page-tag on the very first line) pointing to Index.aspx.cs and the attribute ‘Inherits’ contains the class name of the Page/User-Control class in the code-behind.

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

Sidebar

Related Questions

I have the following code which will generate two pdf files containing plots to
I'm using the following code which will generate a wav file which contains a
The following code will add the categories selector widget to the WordPress Page editor
I have HTML page with following elements <img src='some link' id='_id_portlet1_1234' > link </img>
The following code: using (var db = new Entities()) { db.Blogs.First().Posts.Skip(10).Take(5).ToList(); } Will generate
The following code will generate a compiler error. string GetAgePhrase(int age) { if (age
The following code will search for the user within the domain controller, but I
The following code will log in my application to a server. That server will
Does the following code will increase the allocated memory continuously as it is called
Why the following code will return obvious , surprise! (and lastly how come? ).

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.