0

I want to call a class file to return a boolean value. How do I call the method from my CodeBehindPage. I've tried something like this but it doesn't return the value from my Class file.

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

{
       bool result = true;
       result = Testing.Test123(User.Text, Password.Text);

//Testing is my Class file name and Test123 is the Method name.

       if ((result == true))
             Response.Redirect("~/Test.aspx");
       else
             lblText.Text = "ERROR!";
}

}
}
2
Contributors
3
Replies
6
Views
9 Years
Discussion Span
Last Post by Ramy Mahrous
1

Is Test123 static method??! if not you should initiate instance first from Testing class

Testing _testing = new Testing();
_testing.Test123();
//Test123 should be public
0

My Test123 is a public static. I added what you've said and it shows

Compiler Error Message: CS0176: Member 'Testing.Test123(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.