Transform an asp image to an image vb.net

1

I'm trying to pass the variable <asp:Image ID="imgEstadoRegistro" runat="server"> to the method CheckUserExists(EstadoImagen As Image, EstadoRegistro As String) that is in another class and I miss this error.
The method image CheckUserExists(EstadoImagen As Image, EstadoRegistro As String) comes from Imports System.Drawing

Asp class Login

<asp:TextBox ID="tbUsuarioRegistro" runat="server" CssClass="textoLogin" Height="25px" placeholder="Usuario..." Width="150px" AutoPostBack="true" OnTextChanged="checkUserExists"></asp:TextBox>
<asp:Image ID="imgEstadoRegistro" runat="server" Height="25px" ImageAlign="AbsMiddle" Width="25px" />

Click handle UserHelper (problem in the variable "imgRegistrationState")

Protected Sub checkUserExists(sender As Object, e As EventArgs) Handles tbUsuarioRegistro.TextChanged
    Dim cadenaConexion As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("DSN").ConnectionString)
    UsuarioHelper.CheckUserExists(ConfigurationManager.ConnectionStrings("DSN").ConnectionString, tbUsuarioRegistro.Text().Trim(), imgEstadoRegistro, lbEstadoRegistro.Text)

End Sub

Method to check if the user exists

Public Shared Function CheckUserExists(CadenaConexion As String, Usuario As String, Imagen As Image, LabelEstado As String)
    If (Usuario.Length >= 8) Then
        Dim parUsuario As New SqlParameter("@usuario", Usuario)
        Dim consulta As String = "select usuario from Usuarios where usuario = @usuario"
        Dim objDS As DataSet = SqlHelper.ExecuteDataset(CadenaConexion, CommandType.Text, consulta, parUsuario)

        If (objDS.Tables(0).Rows(0).Item(0)) Then
            Imagen = Image.FromFile("\css\images_css\ic_cancel_black_24dp_1x.png")
        Else
            Imagen = Image.FromFile("\css\images_css\ic_check_black_24dp_1x.png")
            LabelEstado = ""
        End If
    Else
        LabelEstado = "El usuario tiene que tener 8 caracteres minimo"
        Imagen = Image.FromFile("\css\images_css\ic_cancel_black_24dp_1x.png")
    End If
End Function

Thanks for everything, greetings.

    
asked by rencinas 26.10.2016 в 12:40
source

1 answer

0

Ok, after giving a few laps through different websites and thanks to some members of SOes I found a "solution"

I have directly declared the variable Imagen of the method CheckUserExists as System.Web.UI.WebControls.Image , so you do not have to convert it, because both the image of my class as the image of the class are the same format.

It's not the answer I was looking for, but it solves things for me. Thank you all, greetings

    
answered by 27.10.2016 / 13:10
source