xamarin 错误:在类型中找不到具有正确签名的EventHandler“btnLogin_Clicked”

0yycz8jy  于 2023-08-01  发布在  其他
关注(0)|答案(1)|浏览(147)

我正在尝试在Xamarin中创建针对LDAP的身份验证。我有Main.xaml,我在其中创建了简单的登录表单(Entry Placeholder="*Password”IsPassword=“True”x:Name=“login_password”)和按钮(Button Clicked =“btnLogin_Clicked”Text=“Sign in”x:Name=“btnLogin”)。cs包含LDAP连接的代码。我在那里检查凭据并尝试绑定。
我收到这个错误:“在类型'Main.xaml'中未找到具有正确签名的EventHandler 'btnLogin_Clicked'”。
我在这上面花了这么多时间,还是想不出我做错了什么。我将不胜感激,如果任何人可以帮助我与此或给予我一些建议,我可以搜索的答案。
我的代码:

public void btnLogin_Clicked(object sender,string login_username, string login_password, System.EventArgs e)
    {

        string searchBase = "dc = it, dc = local";
        string searchFilter = "(amemberOf=ALL)";
        string ldapHost = "7777.. ";
        int ldapPort = 389;
        string loginDN = "dc = it, dc = local";

        /*if username or passworwd fields are empty show an error*/

        if (login_username is null || login_password is null)
        {
             DisplayAlert("Alert", "Please, enter your credentials", "OK");

        }
        else
        {
            /*creating an LDAP instance*/
            using (LdapConnection connection = new LdapConnection())

                /*here we create new ldap connection*/
                try
                {
                    /*connect function will creat socket connection to the server*/
                    connection.Connect(ldapHost, ldapPort);
                    connection.Bind(string.Format("{0}@{1}", loginDN, login_username), login_password);
                    LdapSearchQueue queue = connection.Search(searchBase,
                    LdapConnection.SCOPE_ONE, searchFilter, null, false, (LdapSearchQueue)
                    null, (LdapSearchConstraints)null);
                    LdapMessage message;

                    while ((message = queue.getResponse()) != null)
                    {
                        if (message is LdapSearchResult)
                        {
                            /*display message if connect*/
                             DisplayAlert("" ," logged in ", "OK ");
                        }
                        else
                        {
                            /*if the message is not null but the login was failed*/
                            DisplayAlert("", "Login failed", "OK ");

                        }...

字符串

w1jd8yoj

w1jd8yoj1#

按钮的事件处理程序具有签名

public void btnLogin_Clicked(object sender, System.EventArgs e)

字符串
您不能只向签名添加额外的参数

相关问题