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 want to generate composite sequences in the following format: <Alphabet><2 digit numeric code>
The following code will not run correctly in IE7 with the latest service packs
Will the following code result in a deadlock using C# on .NET? class MyClass
I have the following code, which will not work. The javascript gives no errors
Consider the following code: $(a).attr(disabled, disabled); In IE and FF, this will make anchors
I found the following code to create a tinyurl.com url: http://tinyurl.com/api-create.php?url=http://myurl.com This will automatically
When IE8 is released, will the following code work to add a conditional stylesheet?
i have the following jquery code. basically i will have several overlapped divs and
I'm trying to write a piece of code that will do the following: Take
I've the following problem, the following code: $link = $_GET['link']; $id = $_GET['block']; echo

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.