i am using this :
<%# Page Title="" Language="C#" MasterPageFile="~/MainMaster.master" AutoEventWireup="true"
Codefile="Admin1.aspx.cs" Inherits="admin1" %>
but one of my website feature is not working ( asyncfileupload ) in hosted server but its working in localhost ...
somehow i got the idea that its happening bcoz of i am using codefile instead of codebehind so my query is how can i use codebehind i have tried this :
<%# Page Title="" Language="C#" MasterPageFile="~/MainMaster.master" AutoEventWireup="true"
CodeBehind="Admin1.aspx.cs" Inherits="admin1" %>
but its give error saying can't load admin1 so what to do now? how can i get my website working?
UPDATE:-
this my .cs file code
public partial class admin1 : System.Web.UI.Page
{
//all the codes
}
Related
I am integrating Asp.net User control(.ascx) in my Mvc Layout page i.e is master page and i am using razor engine.
Error:Error executing child request for handler
'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper ascx.
Control '1_hdfData' of type 'HiddenField' must be placed inside a form tag with runat=server.
This is my code:
_Layout.cshtml:
#Html.Partial("~/UserControls/Data.ascx")
Data.ascx:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Data.ascx.cs" Inherits="MyNameSpace.Data" %>
<asp:HiddenField ID="hdfData" runat="server" />
--Rest all other asp.net server side controls---.
Data.ascx.cs:
namespace MyNameSpace.Data
{
public partial class Data : ViewUserControl
{
//Page_Load events and other code
}
}
Is it like if i am inheriting User Control(.ascx) from ViewUserControl so i cant use asp.net control?
Can anybody help me with this?
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="Data.ascx.cs" Inherits="MyNameSpace.Data" %>
<form runat="server">
<asp:HiddenField ID="hdfData" runat="server" />
--Rest all other asp.net server side controls---.
</form>
I am sharing one idea, but it's not good practice.
#Html.Partial("_ASCX_FILE")
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<%# Register Assembly="SomeAssembly" Namespace="SomeNs" TagName="ASCX_FILE" %>
<ASCX_FILE:SomeControl runat="server" ID="fooControl" />
Possibly above solution can sort out your issue.
Suggesting again, try using pure MVC flavor. :)
I have a web application project in VS2013 with a Master Page and some content pages. My master page header is:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.master.cs" Inherits="MyProject.MasterPage" %>
I then right click on the Master Page in the solution explorer and select "Add Content Page". This produces a content page like the following for me:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="True" CodeBehind="WebForm1.aspx.cs" Inherits="MyProject.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
</asp:Content>
What I do then is right click this "WebForm1" in the solution explorer and change the name to "Login"
This changes the header in the content page to:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="True" CodeBehind="Login.aspx.cs" Inherits="MyProject.WebForm1" %>
Looks fine except it still says Inherits="MyProject.WebForm1" despite that no longer being the name of the content page.
So I figure, "OK I can just change Inherits="MyProject.WebForm1" to Inherits="MyProject.Login". Big mistake, because now I cannot reference any of the controls like TextBox, Label, etc. in my code behind file. I get a list of errors all along the lines of:
The name 'controlname' does not exist in the current context
So it looks like my page can no longer find the class for the controls correctly.
I tried deleting Login.aspx.designer.cs and then recreating it by going to Project -> Convert to web application but that did not work.
So long story short, my code works fine if I use the Inherits="MyProject.WebForm1" despite my page now being called Login. I also tried this with all my other pages and it is the same story.
Is this some kind of bug? Or is my method of adding content pages the problem?
Most likely in your code behind you have this:
namespace MyProject
{
public class WebForm1
This is what your page inherits in terms of the web site prokject, and that is what should be in the "Inhertis" attribute. Note that full class name, including namespace, is expected there.
So if you want to rename your page file - make sure you rename the class as well. Visual Studio does not do this automatically.
I have my html code in the default.aspx page and I am not able to access the onclick of button event on my default.cs page. I am inheriting System.Web.UI.Page in my default.cs page. Is there any way I can get the onclick events in the .cs file
Make sure that your .aspx file contains correct CodeBehind and Inherits:
<%# Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Default.cs" Inherits="Default" %>
If the class of the page specified in Default.cs is within a namespace, make sure to include that into Inherits as well. Like this:
<%# Page Title="" Language="C#" AutoEventWireup="true" CodeBehind="Default.cs" Inherits="MyNamespace.Default" %>
I am really new to C#/VB as a web coding language so apologies early if this is rudimentary
I have a vendor .NET solution i need to add an .aspx page to, which I've managed to do, but there are missing HTML items that are placed by backend .vb file code (we have the uncompiled code as well as the site code)
so for example, Report.aspx
uncompiled
<%# Page Language="vb" AutoEventWireup="false" Inherits="jobber.VU.Report"
CodeFile="Report.aspx.vb" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
compiled
<%# page language="vb" autoeventwireup="false" inherits="jobber.VU.Report,
App_Web_report.aspx.cdcab7d2" enableEventValidation="false" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
the VB backend
Namespace jobber.VU
Partial Class Report
Inherits ActionBase
End Class
End Namespace
How do I replicate that in just an ASPX page?
I tried this
<%# page language="vb" AutoEventWireup="false" Debug="true" %>
<%# Register TagPrefix="VU" Namespace="jobber.VU.Controls" %>
<%# Import Namespace="jobber.VU.ActionBase" %>
<VU:metatags id="headers1" format="none" runat="server"></VU:metatags>
and VU.Controls comes back fine, but the ActionBase class is not executing
I also attempted a <script runat=server, but it never took off the ground
You can have multiple pages inherit from the same page. So if you want to duplicate the functionality of the 'jobber.VU.Report page', just add a new page and inherit from it.
Short story.
This site was created by a friend of mine, who did not know that much C# or asp. And was firstly created in VS 2k3. When i converted it to VS 2k8 these errors started to crop up, there was also other issues with compiling that i managed to sort out ( Seemed to be released to VS 2k8 wanted design files )
Error message gotten:
An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The file '/TestSite/Default.aspx.cs' does not exist.
Source Error:
Line 1: <%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>
Line 2:
Line 3: <asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
Defaults.aspx.cs
namespace GuildStats
{
public partial class _Default : System.Web.UI.Page
{
Defaults.aspx
<%# Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuildStats._Default" %>
Site.master.cs
namespace GuildStats
{
public partial class Site : System.Web.UI.MasterPage { }
}
Site.master
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="GuildStats.Site" %>
In Default.aspx change CodeFile to CodeBehind. You'll probably have to do the same for the Site.master.
See: CodeFile and Code-Behind
Web Site projects use CodeFile, Web Application projects use CodeBehind.
CodeFile requires the source file, it is compiled on the fly when the page is loaded, CodeBehind requires the compiled code.
My guess is that your problem was created when you changed your project type from a WebApp to a Web Site or vice-versa. If you do this, you have to manually change the directives in the existing files, new files will have the right directive automatically.