So an ASP.net project that someone else built about four years ago in Visual Studios 2008 now needs some of its hard coded values changed, and it’s my task to rebuild it. I am using visual studios 2012.
I do not have a good grasp of ASP, as this is not what I normally do. I am having issues with the following bit of (redacted) code:
<%@ Page Language="C#" AutoEventWireup="True"
CodeBehind="CourseList.aspx.cs" Inherits="ah.CourseList" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<% writeCourseList(); %> <!--Compiler complains -->
</form>
</body>
</html>
Visual studios says that “The name ‘writeCourseList’ does not exist in the current context”
I am confused, as writeCourseList is a public method in class CourseList. Also, this code must have compiled at one point since it works on the live server. CourseList class:
namespace ah{
public partial class CourseList: System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
public void writeCourseList()
{ //do stuff}
}
}
Any help would be appreciated. Also, please feel free to advise me on how to better ask this question. Thank you!
Try
You need to return a string from the method when you want to use inline asp.net tags.
inline asp.net tags… sorting them all out (<%$, <%=, <%, <%#, etc.)
But instead i would not use this classis asp style. You should use web databound controls like
GridView, Repeater, ListView,DataListor a simpleListBoxinstead.For example:
You can also
addListItemsmanually: