NHibernate is a small project (six)

xiaoxiao2021-03-06  41

The BLL layer is also completed, now to do the interface, add a newly built ASP.NET web application to create a registered page, (the image is like this)

Using

System;

Using

System.collections;

Using

System.componentmodel;

Using

System.data;

Using

System.drawing;

Using

System.Web;

Using

System.Web.SessionState;

Using

System.Web.ui;

Using

System.Web.ui.WebControls;

Using

System.Web.ui.htmlControls;

Using

Guestbook.bll;

Using

Guestbook.dal;

Using

Guestbook.data;

Namespace

Guestbook.Web

{/ ** ////

/// register's summary description. /// public class Register: System.Web.UI.Page {protected System.Web.UI.WebControls.TextBox txtUserName; protected System.Web.UI.WebControls.TextBox txtEmail; protected System.Web.UI. WebControls.Button Button1; protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1; protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2; protected System.Web.UI.WebControls.RequiredFieldValidator valUN; protected System.Web.UI.WebControls. TextBox txtpwd; private void page_load (object sender, system.eventargs e) {// Place user code here to initialize the page} Web Form Designer Generated Code #REGION Web Form Designer Generated Code Override Protected Void OnInit (Eventargs E) {// // Codegen: This call is required for the ASP.NET Web Form Designer. // InitializeComponent (); base.oninit (e);} / ** //// /// Designer supports the required method - do not use the code editor to modify the // / this method.

/// private void InitializeComponent () {this.Button1.Click = new System.EventHandler (this.Button1_Click); this.Load = new System.EventHandler (this.Page_Load);} #endregion private void Button1_Click (object sender, System.EventArgs e) {if (Page.IsValid) {string username = txtUserName.Text; string Email = txtEmail.Text; string pwd = txtPwd.Text; users newUser = new users (); newUser.Name = username; newuser.email = email; newuser.password = pwd; if (! CreateAccount (newuser)) {Valun.ErrorMessage = "User name has been registered, please searce!"; value;}}} Private Bool CreateAccount (user) {Try {UserSbll BLL = New UserSbll (); BLL.USERADD (USER); HTTPCONTEXT.CURRENT.Session ["Accountinfo"] = User; httpContext.current.response.redirect ("default.aspx", true);} Catch {return false;} return true;}}} This process is overall However, in the final test, I met a little problem, that is, start, I can't insert the data, and then I remembered, I didn't copy NHIBERNATE to Web.config, halo, too careless me

Another thing to pay attention is that

<

Configsections

>

<

section

Name

= "NHibernate"

Type

= "System.configuration.namevaluesectionHandler, System, Version = 1.0.3300.0, Culture = Neutral, PublickeyToken = B77A5C561934E089" />

Configsections

>

The above section must be placed under the tab, and it will be reported in other locations. OK continues

转载请注明原文地址:https://www.9cbs.com/read-68736.html

New Post(0)