ASP.webform1_aspx'不包含'AddRecords'的定义,并且没有扩展方法'AddRecords'接受类型'ASP.webform1_aspx'的第一个参数可以找到(你错过了......) [英] ASP.webform1_aspx' does not contain a definition for 'AddRecords' and no extension method 'AddRecords' accepting a first argument of type 'ASP.webform1_aspx' could be found (are you missing a...

查看:70
本文介绍了ASP.webform1_aspx'不包含'AddRecords'的定义,并且没有扩展方法'AddRecords'接受类型'ASP.webform1_aspx'的第一个参数可以找到(你错过了......)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在4个按钮点击时插入记录



我收到错误



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



I want to insert record on button click with 4 tier

I am getting error

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

 using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }


        protected void AddRecords(object sender, EventArgs e)
        {
            //Lets validate the page first
            if (!Page.IsValid)
                return;

            int intResult = 0;
            // Page is valid, lets go ahead and insert records
            // Instantiate BAL object
          
            PersonBAL pBAL = new PersonBAL();
            // Instantiate the object we have to deal with
            Person person = new Person();
            // set the properties of the object
            person.FirstName = NAME.Text;
            person.LastName = TextBox1.Text;
            person.Year = YEAR.Text;
            person.School = school_name.SelectedValue;
            person.City = TextBox2.Text;
            person.State = TextBox3.Text;
            person.Country = TextBox4.Text;
            person.E_mail = TextBox5.Text;
            person.Mobile = TextBox6.Text;

            //person.Age = Int32.Parse(txtAge.Text);

            try
            {
                intResult = pBAL.Insert(person);
                if (intResult > 0)
                     submit.Text = "New record inserted successfully.";
                else
                    submit.Text = "FirstName [" + TextBox6.Text + "] alredy exists, try another name";

            }
            catch (Exception ee)
            {
                submit.Text = ee.Message.ToString();
            }
            finally
            {
                person = null;
                pBAL = null;
            }
        }
    }
}







我的按钮点击代码




My Button Click code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>

<<body>
    <form id="form1" runat="server">
   
    <ajaxToolkit:ToolkitScriptManager  runat="server" ID="ScriptManager1" />
    <div id="wrap">
<div id="topbar">
  <ul>   
   <li class="current"><a href="#">Home</a></li>

    <li><a href="#">About Us</a></li>
    <li><a href="#">Contact us</a></li>
    <li><a href="#">Register Your Self</a></li>
  </ul>
  </div>
<div id="header">
<div id="sitename">
<h1 id="logo">SUEDP</h1>
</div>
<div id="shoutout"><img src="images/joinnow_shoutout.jpg" alt="Join Now! It's Free" width="168" height="126" /></div>
<div id="useractions">
<div id="headings"> 
<h2><img src="images/create_indi_usr.jpg" alt="Individual User" width="25" height="22" /> <a href="#">Any Time Help</a> </h2>   
<h2>Mr. Rajesh - +919785530723</h2>
<br />
<h2><img src="images/create_indi_usr.jpg" alt="Individual User" width="25" height="22" /> <a href="#">Any Time Help</a> </h2>   
<h2>Mr. Pankil - +919785530723</h2> <br />
 <h2><img src="images/create_indi_usr.jpg" alt="Individual User" width="25" height="22" /> <a href="#">Mail Us</a> </h2>   
<h2> info@suedp@suedp.dahodbazar.com</h2>
   
   <h1>
  <marquee>R & L pandya Celebrate 100 Year Sucess </marquee>
  </h1>
   </div>

</div>

<div id="content">
<div id="home_main">

<div id="search"> 

<ajaxToolkit:Accordion ID="MyAccordion"  runat="server" SelectedIndex="0"

            HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"

            ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40" 

            TransitionDuration="250" AutoSize="Fill" RequireOpenedPane="false" SuppressHeaderPostbacks="true">
           <Panes>
            <ajaxToolkit:AccordionPane ID="AccordionPane1"  runat="server">
                <Header><a href="" class="accordionLink">ENTER YOUR DETAILS</a></Header>

                <Content>

<table class="PANKIL">

<tr>
<td>NAME</td>
<td><asp:TextBox ID="NAME" CssClass="txtbx" runat="server"></asp:TextBox></td>

<td>
LAST NAME
</td>

<td>
<asp:TextBox ID="TextBox1" CssClass="txtbx" runat="server"></asp:TextBox>
</td>



<td>
PASS OUT YEAR
</td>
<td>
<asp:TextBox ID="YEAR" CssClass="txtbx" runat="server"></asp:TextBox>
</td>


</tr>





<tr>
<td>
SCHOOL NAME
</td>

<td>
<asp:DropDownList ID="school_name" runat="server">

<asp:ListItem>R.L.</asp:ListItem>
<asp:ListItem>M.Y.</asp:ListItem>
<asp:ListItem>GIRLS</asp:ListItem>


</asp:DropDownList>
</td>

<td>
CURRENT CITY
</td>
<td>

        <asp:TextBox ID="TextBox2" CssClass="txtbx" runat="server"></asp:TextBox>
</td>
<td>
CURRENT STATE
</td>

<td>

            <asp:TextBox ID="TextBox3" CssClass="txtbx" runat="server"></asp:TextBox>
</td>
</tr>
<tr>


<td>
CURRENT COUNTY
</td>
<td>

                <asp:TextBox ID="TextBox4" CssClass="txtbx" runat="server"></asp:TextBox>
</td>

<td>
E-MAIL
</td>
<td>

                    <asp:TextBox ID="TextBox5"  CssClass="txtbx" runat="server"></asp:TextBox>
</td>
<td>
MOBILE NUMBER
</td>

<td>

                        <asp:TextBox ID="TextBox6" CssClass="txtbx" runat="server"></asp:TextBox>
</td>
</tr>

<tr>
<td>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="AddRecords" />
</td>
</tr>

</table>


</Content>

</ajaxToolkit:AccordionPane>


</Panes>

</ajaxToolkit:Accordion>

    </form>
</body>

推荐答案

Seems like you have defined the AddRecords in one class file and your button click in another class (or aspx page). AddRecords method needs to be in the same class (or page). Suppose you have button in default.aspx page then AddRecords method needs to be defined in default.aspx.cs.
Seems like you have defined the AddRecords in one class file and your button click in another class (or aspx page). AddRecords method needs to be in the same class (or page). Suppose you have button in default.aspx page then AddRecords method needs to be defined in default.aspx.cs.


这篇关于ASP.webform1_aspx'不包含'AddRecords'的定义,并且没有扩展方法'AddRecords'接受类型'ASP.webform1_aspx'的第一个参数可以找到(你错过了......)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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