954,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Accessing control from an aspx page to a seperate .vb class file

Hi !

I am having problems accessing a label on an aspx page to a called function which resides in a seperate .vb file.

My code is as follows:

Login.aspx
========
<asp:label id="lblErrorMessage" runat="server"></asp:label>

BL / PSUrAccount.vb
==============

Public Class WBUserAcct
        I want to access the 'lblErrorMessage' control here..!!
End Class


Thanks,
Adi

luckyads
Light Poster
25 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

No you cant access your page controls in any other class file other than your code behind file. Can U explain what u r trying to achieve. May b there is some work around

Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

Hey thanks!

But I want to seperate out the code in the .vb file and not use it in the .aspx file. I am actually reading an XML file in the code and verifying the username and password with the XML. Here I want to show a message on the Login.aspx page if the username is incorrect and I am writing this code in the .vb file but I am not able to access the lblMessage in the vb file..

Please could you suggest something to work around.

Thanks again!
Adi

luckyads
Light Poster
25 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

One alternative will be to create a function that returns a boolean value that indicates the result of user authentication in your calss file like this
Your .vb file

public shared CheckUserAuthentication() As Boolean
{
   //Authentication code goes here
}

Your .aspx.vb file

if(!MyClass.CheckUserAuthenticaiton())
{
      lblErrorMessageText="Invalid Login Name  and Password "
}
Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

Much thanks!
Will let you know!

-Aditi

luckyads
Light Poster
25 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You