I have 2 files which are copied from Microsoft for testing code behind.
But always show error "Parser Error Message: Could not load type 'MyClass'."
and highlight the aspx file code, Is my server has problem? thx.
Line 1: <%@ Page Language="C#" Inherits="MyCla ss" %>
aspx file content :
<%@ Page Language="C#" Inherits="MyCla ss" %>
<html>
<head>
</head>
<body>
<form id="MyForm" runat="server">
<asp:textbox id="MyTextBox" runat="server" text="Hello
World"></asp:textbox>
<asp:button id="MyButton" onclick="MyButt on_Click" runat="server"
text="Echo Input"></asp:button>
<asp:Label id="MyLabel" runat="server"> </asp:Label>
</form>
</body>
</html>
cs file content :
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.W ebControls;
namespace MyStuff
{
public class MyClass : Page
{
protected System.Web.UI.W ebControls.Labe l MyLabel;
protected System.Web.UI.W ebControls.Butt on MyButton;
protected System.Web.UI.W ebControls.Text Box MyTextBox;
public void MyButton_Click( Object sender, EventArgs e)
{
MyLabel.Text = MyTextBox.Text. ToString();
}
}
} 3 1180
You must compile the code-behind before attempting to inherit.
Also, if you're inheriting from page, the format is as follows :
<%@ Import Namespace="MyNa meSpace" %>
<%@ Page language="C#" Inherits="MyNam eSpace.MyClass" %>
For you, that translates into :
<%@ Import Namespace="MySt uff" %>
<%@ Page language="C#" Inherits="MyStu ff.MyClass" %>
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======
"SAI" <te**@test.co m> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. I have 2 files which are copied from Microsoft for testing code behind. But always show error "Parser Error Message: Could not load type 'MyClass'." and highlight the aspx file code, Is my server has problem? thx.
Line 1: <%@ Page Language="C#" Inherits="MyCla ss" %>
aspx file content : <%@ Page Language="C#" Inherits="MyCla ss" %> <html> <head> </head> <body> <form id="MyForm" runat="server"> <asp:textbox id="MyTextBox" runat="server" text="Hello World"></asp:textbox> <asp:button id="MyButton" onclick="MyButt on_Click" runat="server" text="Echo Input"></asp:button> <asp:Label id="MyLabel" runat="server"> </asp:Label> </form> </body> </html>
cs file content : using System; using System.Web; using System.Web.UI; using System.Web.UI.W ebControls;
namespace MyStuff { public class MyClass : Page { protected System.Web.UI.W ebControls.Labe l MyLabel; protected System.Web.UI.W ebControls.Butt on MyButton; protected System.Web.UI.W ebControls.Text Box MyTextBox;
public void MyButton_Click( Object sender, EventArgs e) { MyLabel.Text = MyTextBox.Text. ToString(); } } }
I use following method to compile. Is it right? thanks.
csc.exe /out:mycodebehin d.dll /t:library mycodebehind.cs
"Juan T. Llibre" <no***********@ nowhere.com> ¼¶¼g©ó¶l¥ó·s»D: %2************* **@TK2MSFTNGP10 .phx.gbl... You must compile the code-behind before attempting to inherit.
Also, if you're inheriting from page, the format is as follows :
<%@ Import Namespace="MyNa meSpace" %> <%@ Page language="C#" Inherits="MyNam eSpace.MyClass" %>
For you, that translates into : <%@ Import Namespace="MySt uff" %> <%@ Page language="C#" Inherits="MyStu ff.MyClass" %>
Juan T. Llibre ASP.NET MVP http://asp.net.do/foros/ Foros de ASP.NET en Español Ven, y hablemos de ASP.NET... =============== =======
"SAI" <te**@test.co m> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..I have 2 files which are copied from Microsoft for testing code behind. But always show error "Parser Error Message: Could not load type 'MyClass'." and highlight the aspx file code, Is my server has problem? thx.
Line 1: <%@ Page Language="C#" Inherits="MyCla ss" %>
aspx file content : <%@ Page Language="C#" Inherits="MyCla ss" %> <html> <head> </head> <body> <form id="MyForm" runat="server"> <asp:textbox id="MyTextBox" runat="server" text="Hello World"></asp:textbox> <asp:button id="MyButton" onclick="MyButt on_Click" runat="server" text="Echo Input"></asp:button> <asp:Label id="MyLabel" runat="server"> </asp:Label> </form> </body> </html>
cs file content : using System; using System.Web; using System.Web.UI; using System.Web.UI.W ebControls;
namespace MyStuff { public class MyClass : Page { protected System.Web.UI.W ebControls.Labe l MyLabel; protected System.Web.UI.W ebControls.Butt on MyButton; protected System.Web.UI.W ebControls.Text Box MyTextBox;
public void MyButton_Click( Object sender, EventArgs e) { MyLabel.Text = MyTextBox.Text. ToString(); } } }
Yes, and if you need to reference a .Net Framework class,
add /r: classname.dll /r:anotherclassn ame.dll to the command :
csc.exe /t:library /r:system.dll /r:system.web.dl l /out:cb.dll cb.cs
I shortened the filename and dll name to fit the command in one line.
Substitute your own names, of course.
If you want a number of files compiled into a single assembly, just put
all your .cs files into a directory and use a wildcard in the command :
csc.exe /t:library /r:system.dll /r:system.web.dl l /out:cb.dll *.cs
Juan T. Llibre
ASP.NET MVP http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
=============== =======
"SAI" <te**@test.co m> wrote in message news:uP******** ******@TK2MSFTN GP12.phx.gbl... I use following method to compile. Is it right? thanks.
csc.exe /out:mycodebehin d.dll /t:library mycodebehind.cs
"Juan T. Llibre" <no***********@ nowhere.com> ¼¶¼g©ó¶l¥ó·s»D: %2************* **@TK2MSFTNGP10 .phx.gbl... You must compile the code-behind before attempting to inherit.
Also, if you're inheriting from page, the format is as follows :
<%@ Import Namespace="MyNa meSpace" %> <%@ Page language="C#" Inherits="MyNam eSpace.MyClass" %>
For you, that translates into : <%@ Import Namespace="MySt uff" %> <%@ Page language="C#" Inherits="MyStu ff.MyClass" %>
Juan T. Llibre ASP.NET MVP http://asp.net.do/foros/ Foros de ASP.NET en Español Ven, y hablemos de ASP.NET... =============== =======
"SAI" <te**@test.co m> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..I have 2 files which are copied from Microsoft for testing code behind. But always show error "Parser Error Message: Could not load type 'MyClass'." and highlight the aspx file code, Is my server has problem? thx.
Line 1: <%@ Page Language="C#" Inherits="MyCla ss" %>
aspx file content : <%@ Page Language="C#" Inherits="MyCla ss" %> <html> <head> </head> <body> <form id="MyForm" runat="server"> <asp:textbox id="MyTextBox" runat="server" text="Hello World"></asp:textbox> <asp:button id="MyButton" onclick="MyButt on_Click" runat="server" text="Echo Input"></asp:button> <asp:Label id="MyLabel" runat="server"> </asp:Label> </form> </body> </html>
cs file content : using System; using System.Web; using System.Web.UI; using System.Web.UI.W ebControls;
namespace MyStuff { public class MyClass : Page { protected System.Web.UI.W ebControls.Labe l MyLabel; protected System.Web.UI.W ebControls.Butt on MyButton; protected System.Web.UI.W ebControls.Text Box MyTextBox;
public void MyButton_Click( Object sender, EventArgs e) { MyLabel.Text = MyTextBox.Text. ToString(); } } }
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John |
last post by:
Hi,
I have an asp.net form where if the user enters an
incorect date I change the color of the textbox to red and
also display a label field with a message saying the date
is invalid. What I would like to do is to have some way to
trap the event where the user changes the date and reset
the color of the textbox to white and change the error
lablel to hidden. I want to do this before the page gets
submitted back to the server so I've...
|
by: Karl Hungus |
last post by:
If I use a code behind class for an aspx page, what is the best way to get
data from the codebehind class into my aspx page?
I know about databinding, but is there a more basic way of just referencing
the variables or calling getters?
thanks in advance
|
by: Dot net work |
last post by:
Hi,
Is it possible to do a form POST and also redirect to a different url,
using code behind?
I don't think response.redirect will work because that doesn't post
form data.
I don't think server.transfer will work because that doesn't redirect
to a different url.
I don't think HttpWebRequest will work because that doesn't redirect
|
by: Derek Martin |
last post by:
Hi list, I have been doing VB.Net for quite a while now and just now getting
into the forray of ASP.Net using VS2003. I have created our development
website and now we are ready to start putting it into production.
I've messed around with a few different deployment scenarios but the one we
ended up with was two copies of the code, one on dev and one on prod and all
changes we make to code on dev have to be copied to the prod and then...
|
by: dinesh |
last post by:
I'm converting an app written using the pure .net framework from command
line, to Visual studio 2003. Having a problem with the datalist that wasnt
there before:
e:\inetpub\wwwroot\WebApplication2\winelist.aspx.cs(38): The type or
namespace name 'MyList' could not be found (are you missing a using directive
or an assembly reference?)
MyList.DataSource = productlist.gettheitems(color, category, year, region,
appellation, country);
| |
by: Tony Johansson |
last post by:
Hello!
I'm new to ASP.NET application but I have been using C# windows form for one
year.
I'm reading a book about Webbdevelopment.
Below is a small ASP.NET application.
I just wonder why is it not any class like it is in the window form like
this
public class Test : Forms
|
by: Bill44077 |
last post by:
Hi,
I am new to the MVP pattern and one of the main reasons that we are going
this route is because we are doing Scrum with 30 day sprints - so we have a
continually morphing design. We are using TDD as well to improve our ability
to refactor... you probably all know this approach.
Although the user iterface is supposedly one of the last things that you
need to do, this is a web app and we have multiple nested Repeaters on the
page....
|
by: Gilbert |
last post by:
Hi,
In the code-behind, i have this function:
Public Function myfunction(ByVal myvar As Object) As String
dim x as string = myvar
.....
Return x
End Function
|
by: archana |
last post by:
Hi all,
I am new to asp.net. I have one question regarding code- behind model.
I have written page_load event in code behind as well as in aspx page.
Means i am doing mixing of code-behind as well as single file model.
Is it possible to write some code in code behind and some in aspx page
itself.
|
by: pb |
last post by:
Hi,
I have built a page with some generic functions in the code behind -
all works fine.
I then wanted to put these functions in their own code modules, so in
the app_code folder I created class1.vb with the content such as...
------------------------------------------------
Imports Microsoft.VisualBasic
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |