Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more: (untagged)
Hi,

I have a CS file in appcode FHAConnClass.cs , now i need to call a method of XMLValidator.aspx.cs file.How can i do that?

C#
namespace FHAConnTester
{ 
    public class FHAConnClass
    {

        public string ReadTest()
       { 
//I want to call the method of aspx.cs
     requestXML ();
       }


XMLValidator.aspx.cs

C#
namespace LoanScore
{
    public partial class XMLValidator : System.Web.UI.Page
    {
       public void requestXML()
        {//Do something
        }
    }
}


XMLValidator.aspx
C#
<%@ Page Language="C#"  AutoEventWireup="true" CodeFile="XMLValidator.aspx.cs" Inherits="LoanScore.XMLValidator" Title="XML Validator"   MasterPageFile="~/master/MasterPage.master"%>
Posted
Comments
Rockstar_ 24-Jul-12 3:21am    
Make ur method as Static, and access with the classname and methodname.......
Ali_100 24-Jul-12 3:44am    
after
public static void requestXML()
{//Do something
}
i can't access
XMLValidator.requestXML();

was i follow u rightly ? can u tell me the other one?

1 solution

The easiest way is to move the requestXML function to another class. Methods in your Page class should be events like Load and server control events. Don't put common functionality here. That's bad practice.
You could solve this by using statics, but it's bad architecture.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900