asp.net - Content Controls Have to Be Top Level -
im making website sends information mysql server, using asp.net. code. problem im having when debug code , launch page, error:
[httpexception (0x80004005): content controls have top-level controls in content page or nested master page references master page.] system.web.ui.masterpage.createmaster(templatecontrol owner, httpcontext context, virtualpath masterpagefile, idictionary contenttemplatecollection) +9633920 system.web.ui.page.get_master() +54 system.web.ui.page.applymasterpage() +14 system.web.ui.page.performpreinit() +45 system.web.ui.page.processrequestmain(boolean includestagesbeforeasyncpoint, boolean includestagesafterasyncpoint) +335
im not sure why, have error. have tried making new webpage , else. here code:
default.aspx
<%@ page title="home page" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default"%> <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> </td> <td> <asp:button id="btnsave" runat="server" text="save" onclick="btnsave_click" /> </td> </tr> <tr> <td> </td> <td> <asp:label id="lblerror" runat="server" text=""></asp:label> </td> </tr> </table> </div> </form>
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=3306;database=ci_series;uid=bugalicious;pwd=comeonoutohtheweatheroutsideisweather1!"; 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? cant figure out. in advance!
Comments
Post a Comment