asp.net - " " Does not exist in current context? -


im making website sends information mysql server, using asp.net. code. problem im having when debug code , launch page, these error:

enter image description here

im not sure why, have error. here code:

default.aspx

<%@ page title="home page" language="c#" masterpagefile="~/site.master"                 autoeventwireup="true"         codefile="default.aspx.cs" inherits="_default"%>         <asp:content id="bodycontent" runat="server" contentplaceholderid="maincontent">     <form id="form1" runat="server">     <div>     <table width="300px" >     <tr>     <td>first name</td>     <td>         <asp:textbox id="txtfirstname" runat="server"></asp:textbox>         </td>     </tr>         <tr>     <td >last name</td>     <td>         <asp:textbox id="txtlastname" runat="server"></asp:textbox>             </td>     </tr>         <tr>     <td>user name</td>     <td>         <asp:textbox id="txtusername" runat="server"></asp:textbox>             </td>     </tr>         <tr>     <td>password</td>     <td>         <asp:textbox id="txtpassword" runat="server"></asp:textbox>             </td>     </tr>         <tr>     <td>email address</td>     <td>         <asp:textbox id="txtemail" runat="server"></asp:textbox>             </td>     </tr>         <tr>     <td>&nbsp;</td>     <td>         <asp:button id="btnsave" runat="server" text="save" onclick="btnsave_click" />             </td>     </tr>         <tr>     <td>&nbsp;</td>     <td>         <asp:label id="lblerror" runat="server" text=""></asp:label>             </td>     </tr>     </table>     </div>     </form>     </asp:content id="content1" runat="server" contentplaceholderid="maincontent"> 

default.aspx.cs

    public partial class _default : system.web.ui.page     { protected void page_load(object sender, eventargs e) {  } protected void btnsave_click(object sender, eventargs e) {     try     {          string cnnstring = "server=localhost;port=1111;database=ci_series;uid=asdfasdf;pwd=*******";           mysqlconnection connection = new mysqlconnection(cnnstring);           string cmdtext = "insert membership (first_name ,last_name ,username ,password ,";         cmdtext += "email_address)values (first_name ,last_name ,username ,password ,email_address);";          mysqlcommand cmd = new mysqlcommand(cmdtext, connection);           cmd.commandtype = commandtype.text;         cmd.parameters.add("?first_name", mysqldbtype.varchar).value = txtfirstname.text;         cmd.parameters.add("?last_name", mysqldbtype.varchar).value = txtlastname.text;         cmd.parameters.add("?username", mysqldbtype.varchar).value = txtusername.text;         cmd.parameters.add("?password", mysqldbtype.varchar).value = txtpassword.text;         cmd.parameters.add("?email_address", mysqldbtype.varchar).value = txtemail.text;          connection.open();          int result = cmd.executenonquery();          lblerror.text = "data saved";      }     catch (exception ex)     {         lblerror.text = ex.message;     } }     } 

how fix this? "not exist in current context" mean? in advance!

1) make sure runat="server" on html tag on master page.

2) error due , assembly caching problem because vs gets confused needs recompiled. -- delete cache items , recompile normally, figuring more 1 thing may wrong


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -