错误是"btnSubmit_Click"不是"ASP.mycomment_aspx"的成员. [英] the error is 'btnSubmit_Click' is not a member of 'ASP.mycomment_aspx'.

查看:195
本文介绍了错误是"btnSubmit_Click"不是"ASP.mycomment_aspx"的成员.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码...


html文件..

this is the my code...


html file ..

<tr>
Line 25: <td></td>
Line 26: <td><asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" /></td>
Line 27: </tr>
Line 28: </table>



这是vb代码



this is vb code

Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)

            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("insert into [User] (Username,Subject,Comment,PostedDate) values(@UserName,@Subject,@Comment,@PostedDate)", con)
            cmd.Parameters.AddWithValue("@userName", txtName.Text)
            cmd.Parameters.AddWithValue("@subject", txtSubject.Text)
            cmd.Parameters.AddWithValue("@comment", txtComment.Text)
            cmd.Parameters.AddWithValue("@postedDate", DateTime.Now)
            cmd.ExecuteNonQuery()
            con.Close()
            txtName.Text = String.Empty
            txtSubject.Text = String.Empty
            txtComment.Text = String.Empty
            BindRepeaterData()
        End Sub
        Protected Sub BindRepeaterData()
            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("select * from [User] Order By PostedDate desc", con)
            Dim ds As New DataSet()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(ds)
            If ds.Tables(0).Rows.Count > 0 Then
                RepDetails.Visible = True
                RepDetails.DataSource = ds
                RepDetails.DataBind()
            Else
                RepDetails.Visible = False
            End If

            con.Close()
        End Sub

推荐答案

嗨......

不要在按钮标记中写入onclick,它会调用javascipr function.onclick事件,以尝试搜索名称为"btnSubmit_Click"的javascript函数.如果要在javascript中调用此函数,请写入onclientclick.if. .双击按钮可直接在后面的代码中生成方法.
希望对您有帮助.

Aspx代码为

< asp:Button ID ="btnSubmit" runat ="server" Text ="Submit"/>


在后面的代码中编写代码:

hi......

Dont write onclick in button tag it call javascipr function.onclick event it trying to search javascript function with name "btnSubmit_Click".If you want to call this function in javascript write onclientclick.if you want to write function in code bahind remove the onclick syantax.double click on button it generates method in the code behind directly.
i hope it will helps you.

Aspx Code is

<asp:Button ID="btnSubmit" runat="server" Text="Submit" />


write a code in code behind:

Protected Sub btnSubmit_Click(sender As Object, e As EventArgs)Handles ButtonAdd.Click

            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("insert into [User] (Username,Subject,Comment,PostedDate) values(@UserName,@Subject,@Comment,@PostedDate)", con)
            cmd.Parameters.AddWithValue("@userName", txtName.Text)
            cmd.Parameters.AddWithValue("@subject", txtSubject.Text)
            cmd.Parameters.AddWithValue("@comment", txtComment.Text)
            cmd.Parameters.AddWithValue("@postedDate", DateTime.Now)
            cmd.ExecuteNonQuery()
            con.Close()
            txtName.Text = String.Empty
            txtSubject.Text = String.Empty
            txtComment.Text = String.Empty
            BindRepeaterData()
        End Sub
        Protected Sub BindRepeaterData()
            Dim con As New SqlConnection("Data Source=KARANDE\sqlexpress;Initial Catalog=nitink;Integrated Security=True")
            con.Open()
            Dim cmd As New SqlCommand("select * from [User] Order By PostedDate desc", con)
            Dim ds As New DataSet()
            Dim da As New SqlDataAdapter(cmd)
            da.Fill(ds)
            If ds.Tables(0).Rows.Count > 0 Then
                RepDetails.Visible = True
                RepDetails.DataSource = ds
                RepDetails.DataBind()
            Else
                RepDetails.Visible = False
            End If

            con.Close()
        End Sub


这篇关于错误是"btnSubmit_Click"不是"ASP.mycomment_aspx"的成员.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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