Asp.login_aspx不包含loginbtn_click的定义,也没有扩展方法 [英] Asp.login_aspx does not contain a definition for loginbtn_click and no extension method

查看:202
本文介绍了Asp.login_aspx不包含loginbtn_click的定义,也没有扩展方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好朋友我收到此错误:







编译器错误消息:'ASP.login_aspx '不包含'LoginBtn_Click'的定义,并且没有扩展方法'LoginBtn_Click'接受类型'ASP.login_aspx'的第一个参数可以找到(你是否缺少using指令或汇编引用?)



来源错误:





< asp:按钮ID =LoginBtnValidationGroup = LoginValidation

runat =serverText =Loginonclick =LoginBtn_Click/>< br />





我有'LoginBtn_Click'的定义。

Aspx页面编码

< asp:Button ID =LoginBtnValidationGroup =LoginValidation

runat =serverText =Loginonclick =LoginBtn_Click/>





Aspx.cs编码



Hello Friends I got this Error:



Compiler Error Message: 'ASP.login_aspx' does not contain a definition for 'LoginBtn_Click' and no extension method 'LoginBtn_Click' accepting a first argument of type 'ASP.login_aspx' could be found (are you missing a using directive or an assembly reference?)

Source Error:


<asp:Button ID="LoginBtn" ValidationGroup="LoginValidation"
runat="server" Text="Login" onclick="LoginBtn_Click"/><br />


I have a definition for 'LoginBtn_Click'.
Aspx Page Coding
<asp:Button ID="LoginBtn" ValidationGroup="LoginValidation"
runat="server" Text="Login" onclick="LoginBtn_Click"/>


Aspx.cs Page Coding

protected void LoginBtn_Click(object sender, EventArgs e)
     {
         string ConnectionString = ConfigurationManager.ConnectionStrings["BankDatabaseConnectionString"].ConnectionString;
         DataSet myset = new DataSet();
         try
         {
             using (SqlConnection con = new SqlConnection(ConnectionString))
             {
                 using (SqlCommand cmd = new SqlCommand("Select * from Users where Email=@User_ID and Password=@Password", con))
                 {
                     cmd.CommandType = CommandType.Text;
                     cmd.Parameters.Add(new SqlParameter("@User_ID", SqlDbType.VarChar, 200));
                     cmd.Parameters["@User_ID"].Value = UserIdtxt.Text;
                     cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar, 15));
                     cmd.Parameters["@Password"].Value = Passwordtxt.Text;
                     con.Open();
                     using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                     {
                         sda.Fill(myset);
                     }

                 }
             }
             if (myset.Tables[0].Rows.Count > 0)
                 LabelMsg.Text = "Login Successful!";
             else
                 LabelMsg.Text = "Incorrect Credentials!";

         }
         catch (Exception ex)
         {
             LabelMsg.Text = "Exception Occured while Saving: " + ex.Message;
         }
     }

 }









请查看并帮我解决这个问题。



我尝试过的事情:



我删除了aspx.cs页面中的LoginBtn_Click事件并创建了一个新的Click事件,但我又得到了这个错误





Please check it out and help me to resolve this.

What I have tried:

I deleted the LoginBtn_Click Event in aspx.cs Page and Created a New Click Event,but again I got this Error

推荐答案

这不是编译错误,其运行时错误



<大> 尝试以下步骤:



确保 aspx 后面的代码( .cs )是同步的。



右键单击设计视图并单击查看代码并确保它转到正确的代码隐藏文件,如果没有,则将其映射到相关文件在页面指令中。



删除现有的按钮并在标记设计视图中创建一个新的并右键单击按钮 - > ;转到属性 - >转到活动标签( flash符号) - >双击'点击'行,它将为按钮生成一个事件,现在你可以 clean build 解决方案并检查,它应该可以工作。
This not Compile error, Its Run Time error.

Try these steps:

Make sure that aspx and code behind (.cs) are in sync.

right click the page in design view and click "view code" and make sure it goes to the right code behind file, if not then map it to the concerned file in the Page directive.

Delete the existing button and create a new one in mark up or in design view and right click the button -> go to properties -> go to events tab (flash symbol) -> double click the 'Click' row, it will generate an event to the button, now you can clean and build the solution and check, it should work.


这篇关于Asp.login_aspx不包含loginbtn_click的定义,也没有扩展方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆