Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: other Calls
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?
 
   
namespace FHAConnTester
{ 
    public class FHAConnClass
    {
 
        public string ReadTest()
       { 
//I want to call the method of aspx.cs
     requestXML ();
       }
 

 
XMLValidator.aspx.cs
 
 

namespace LoanScore
{
    public partial class XMLValidator : System.Web.UI.Page
    {
       public void requestXML()
        {//Do something
        }
    }
}
 
 
XMLValidator.aspx
<%@ Page Language="C#"  AutoEventWireup="true" CodeFile="XMLValidator.aspx.cs" Inherits="LoanScore.XMLValidator" Title="XML Validator"   MasterPageFile="~/master/MasterPage.master"%>
Posted 23-Jul-12 21:12pm
Ali_1001.3K
Comments
VijayChauhan123 at 24-Jul-12 3:21am
   
Make ur method as Static, and access with the classname and methodname.......
Ali_100 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 530
1 Sergey Alexandrovich Kryukov 340
2 BillWoodruff 259
3 PIEBALDconsult 230
4 CPallini 220
0 Sergey Alexandrovich Kryukov 10,615
1 Maciej Los 5,354
2 OriginalGriff 5,254
3 CPallini 3,719
4 BillWoodruff 3,476


Advertise | Privacy | Mobile
Web02 | 2.8.141029.1 | Last Updated 14 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100