asp.net - How to create multiple code behind file for .aspx page -


i have situation need create multiple code behind files single .aspx page in c# asp.net. have web form on huge coding done , need multiple developer's working on simultaneously. how can achieve same?

here code snippet tried

class 1 mypartialclass.cs

namespace webapplication1 {     public partial class default : system.web.ui.page     {         protected void printtext(string pt)         {             response.write(pt);             //lbltest.text = pt;    //can not access label in partial class.         }     } } 

class 2 default.aspx.cs

namespace webapplication1 {     public partial class default : system.web.ui.page     {         protected void page_load(object sender, eventargs e)         {             printtext("hello world");         }     } } 

and html source

<%@ page language="c#" autoeventwireup="false" codebehind="default.aspx.cs" inherits="webapplication1.default" %>  <!doctype html>  <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:label id="lbltest" runat="server"></asp:label>     </div>     </form> </body> </html> 

asp.net generate code behind files partial classes

namespace webapplication1 {     public partial class default : system.web.ui.page     {         protected void page_load(object sender, eventargs e)         {          }     } } 

you can therefor separate code behind in different files, if pertain definition partial , keep class under same namespace.

edit : web project

//default.aspx <%@ page title="home page" language="c#" masterpagefile="~/site.master"     autoeventwireup="true"     codebehind="default.aspx.cs" inherits="webapplication1.default" %>  <asp:content id="headercontent" runat="server" contentplaceholderid="headcontent"> </asp:content> <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent">     <asp:label id="lbltest" runat="server" text="label"></asp:label> </asp:content>  //default.aspx.cs namespace webapplication1 {     public partial class default : system.web.ui.page     {         protected void page_load(object sender, eventargs e)         {             printtext("hello world");         }     } }  //mypartialclass.cs namespace webapplication1 {     public partial class default     {         protected void printtext(string pt)         {             response.write(pt);             lbltest.text = pt;    //lbltest accessible here         }     } } 

i haven't modified other generated files. 1 thing mention default.aspx.cs file has been generated generated class name "_default". have changed default , visual studio refactored change across files contain definition class, except default.aspx file, had manually modifiy inherits="webapplication1._default" inherits="webapplication1.default".

edit 2:

i kept searching internet, , according http://codeverge.com/asp.net.web-forms/partial-classes-for-code-behind/371053, trying impossible. same idea detailed @ http://codeverge.com/asp.net.web-forms/using-partial-classes-to-have-multiple-code/377575 if possible, consider converting web site web application, supports trying achieve. here walkthrough on how perform conversion: http://msdn.microsoft.com/en-us/library/vstudio/aa983476(v=vs.100).aspx


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -