0

hi,

my project involving ASP.net & i write a code uisng VB.net.
i have design few checkbox in ASP.net and would like to write class function in class file.
can anyone guide me how to create and call the function from the class to the page.
i have create a class file as below

Public Class clsKYC

    Public Function InfoCheking(ByVal SignVerified As String, ByVal CTOSChkd As String, ByVal BursaChckd As String, ByVal AMLAChkd As String, ByVal FRCChkd As String, ByVal DFCChckd As String, ByVal BenChkd As String)

        If SignVerified = False Then
            Return "please clicked"
            Exit Function
        ElseIf CTSChkd = False Then
            Return "please clicked"
            Exit Function
        ElseIf rsaChckd = False Then
            Return "please clicked"
            Exit Function
        ElseIf AMChkd = False Then
            Return "please clicked"
            Exit Function
        ElseIf FRCChkd = False Then
            Return "please clicked"
            Exit Function
        ElseIf FCChckd = False Then
            Return "Invalid source directory"
            Exit Function
        ElseIf BnChkd = False Then
            Return "please clicked"
            Exit Function
        Else
            Return "please clicked"
            Exit Function
        End If

    End Function

End Class

then from the page i call like as below :

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        If clsKYC.InfoCheking(checkbox1.Checked) Then
            textbox1.Enabled = True
        Else
            textbox1.Enabled = False
        End If


    End Sub

but i think there is wrong some where but i have no idea. can anyone guide me.plz

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by spectra
0

Can you elaborate on what you are trying to do? It's not clear to me based on your description and code provided.

0

The first thing: Your InfoCheking function should accept only one parameter, type of Checkbox. Next thing, as you have the same exit of function for several conditions, you could put all of those which are behaving similar, under one IF statement, in the order which is required. So it will check one by one condition, and as soon as it finds one which is false, it will exit from the function.
I consider that SignVerified, CTSChkd etc. are your checkbox controls names.

Public Function InfoChecking(ByVal chkBox As CheckBox)
                    If (chkBox.Name = "SignVerified" And chkBox.Checked = False) Or
                        (chkBox.Name = "CTSChkd" And chkBox.Checked = False) Or
                        (chkBox.Name = "rsaChckd" And chkBox.Checked = False) Or
                        (chkBox.Name = "AMChkd" And chkBox.Checked = False) Or
                        (chkBox.Name = "FRCChkd" And chkBox.Checked = False) Or
                    Then
                        Return "please clicked"
                        Exit Function
                    ElseIf (chkBox.Name = "FCChckd" And chkBox.Checked = False)
                    Then
                        Return "Invalid source directory"
                        Exit Function
                    ElseIf (chkBox.Name = "BnChkd" And chkBox.Checked = False)
                    Then
                        Return "please clicked"
                        Exit Function
                    Else
                        Return "please clicked"
                        Exit Function
                    End If
     End Function

In that way you will call function like:

clsKYC.InfoChecking(checkbox1)

The second thing, your condition in the page code does not have correct number of parameters (as you have in your function definition, so it is not clear what are you calling). And even in the case you intended to call the function, that line
4. If clsKYC.InfoCheking(checkbox1.Checked) Then

will always return TRUE (as the function InfoCheking returns some string (ie. "please clicked"), and it is considered as true.)
I am not sure what you really want to get, but either function output or this IF statement should be changed.

Edited by spectra

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.