Unit 8.3 Learning Objectives Insert users into the ASP.NET Membership system from code Capture data being sent to the database Capture Exceptions that.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the: course is a PowerPoint demonstration intended to introduce.
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the: course is a PowerPoint demonstration intended to introduce.
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the: course is a PowerPoint demonstration intended to introduce.
Course Form In the main window (cf. Figure 2), click on Forms, then double-click on Create form by using wizard. Follow the sequence of actions below.
MY NCBI (module 4.5). MODULE 4.5 PubMed/How to Use MY NCBI Instructions - This part of the:  course is a PowerPoint demonstration intended to introduce.
MY NCBI (module 4.5).
MS-Access XP Lesson 1. Introduction to MS-Access Database Management System Software (DBMS) Store data in databases Database is a collection of table.
Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
Enlighten V2.2 Manual – User Level Access
1 Unit & District Tools Phase 1. 2 To access the new Unit and District Tools, you will need to click on the link embedded in the MyScouting Flash page.
Using Macros and Visual Basic for Applications (VBA) with Excel
Members Only & Login Modules Members Only works with the Login module to provide password protection to Web pages and files. Login Groups may be created.
MIS 3200 – Unit 4 Complex Conditional Statements – else if – switch.
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Inventory Throughout this slide show there will be hyperlinks (highlighted in blue) follow the hyperlinks to navigate to the specified Topic or Figure.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
So – You want to learn how to put an advanced article submission (cut and paste) onto the state website. (Note: If you have not done so, you will need.
Panorama High School E.G.P./ Training to Put Students’ Grades on the Website Wednesday, September 29,
MIS 3200 – Unit 6.2 Learning Objectives How to move data between pages – Using Query Strings How to control errors on web pages – Using Try-catch.
Unit 8.2 Learning Objectives How data can be used – The Money Ball Example The Money Ball Example Data Warehouses – The Role of Data Warehouses The Role.
Event Manager Training Part 3.  Edit Event Options - Customize FY11 Sites  Edit Event Webpages  Sending s (Recruitment/Engagement)  Help and.
Address Refer to Slide 2 for instructions on how to view the full-screen slideshow.Slide 2.
Career Services Center Employer Training. This is the main login page. The link can be found at Employers.
Introduction to the WebBoard Terry Dennis. The WebBoard - Our Connection The WebBoard URL is
Creating a Web Site to Gather Data and Conduct Research.
PHP meets MySQL.
UNIT 9.2 Learning Objectives A Real world Application of Databases – The Money Ball Example The Money Ball Example Data Warehouses – The Role of Data Warehouses.
UNIT 9.2: Learning Objectives Agile Development – Bruce Feiler on Agile Programming Database access from code – Database Cycle Review – SQL Command Types.
Credit Union National Association Installing and Uploading Project Zip Code.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
© 2003 Everett Public Schools Information Systems and Technology Department Getting Started with FirstClass October 10, 2015.
TxEIS Security A role-based solution October 2010.
C# Tutorial -1 ASP.NET Web Application with Visual Studio 2005.
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Basic & Advanced Reporting in TIMSNT ** Part Two **
Downloading and Installing Autodesk Revit 2016
CSC 240 (Blum)1 Forms and Importing Data in Access.
Office Management Tools II Ms Saima Gul. Office Management Tools II Ms Saima Gul.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
1 What to do before class starts??? Download the sample database from the k: drive to the u: drive or to your flash drive. The database is named “FormBelmont.accdb”
Microsoft Access 2010 Chapter 10 Administering a Database System.
Downloading and Installing Autodesk Inventor Professional 2015 This is a 4 step process 1.Register with the Autodesk Student Community 2.Downloading the.
What is Web Site Administration Tool ? WAT Allow you to Configure Web Site With Simple Interface –Manage Users –Manage Roles –Manage Access Rules.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Unit 8.2 Learning Objectives Data Warehouses – The Role of Data Warehouses The Role of Data Warehouses – Group Exercise Accessing Data in Views – Accessing.
Navigation: If the tutorial opens up in your web browser, simply click your mouse to advance to the next slide. Use the “Backspace”
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Beginning ASP.NET in C# and VB Chapter 9
Working with ASP.NET Controls What is ASP.NET Using server controls in your pages Allowing users to create their own accounts Creating a login page Letting.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Henrik Kjems-Nielsen ICES Secretariat InterCatch – the screen guide.
Child Care Subsidy Program Online Billing Provider Training Spring 2016.
1 Logging into the new PCard (PaymentNet) System: PAYMENTNET * Introduction * May use IE 8.0 or greater or Firefox * Do not.
Downloading and Installing GRASP-AF Workshop Ian Robson Information Analyst, North of England Cardiovascular Network.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 11 Creating Web Applications and Writing Data to a Database.
Unit & District Tools Phase 1
Unit 7 Learning Objectives
Unit 9.1 Learning Objectives Data Access in Code
Unit 8.1: Introducing Databases
Unit 8.2 How data can be used Accessing Data in Views
Unit 9.2 Database access from code Database Cycle Review
Unit 27 - Web Server Scripting
Navigating NEIU Blackboard 417 – 418a
Complete exercise 8-11 in the workbook.
Presentation transcript:

Unit 8.3 Learning Objectives Insert users into the ASP.NET Membership system from code Capture data being sent to the database Capture Exceptions that happen at the database Concepts on this Unit are Excluded from final exam

ASP.Net Membership Unit 7 demonstrated ASP.NET Membership controls to – Configure security using the ASP.NET Configuration option Create users Create roles Create access rules – Use.NET controls Create new users Login Display login status and login name

Import a library of special tools (i.e. namepsace) Namespace contains “Membership” functionality – MemberShipCreateStatus – Membership Adding Users using Custom Code using System.Web.Security; MemberShipCreateStatus status; MemberShip.CreateUser (username, password, …, status)

A great example… “user”, “password”, “passwordQuestion”, and “passwordAnswer” are all string variables and all have values This means that the status is returned from the method, all other data is sent into the method This could mean bad data, duplicate user names, missing or weak password Things can always go wrong so attempting to create a user in code should always be in a try/catch block. If an Exception does occur, show it to the user.

Events related to Data Controls Occur with Insert, Update (Edit), or Delete With Data bound controls (e.g. DetailsView) In the following order 1. ItemInserting (or IteamUpdating, or ItemDeleting) 2. Inserting 3. Inserted 4. ItemInserted 5. ….

How the event method handles user info This shows how you can get to the same data in code if you know the database field name

More event processing Event methods ending in “ed” occur after the event and provide a way for us to see what happened as in this DetailsView ItemInserted even method… Number of rows affected by command This lets you see the Exception was, i.e. an attempt to insert a duplicate key i.e. the user was already in the database

Testing for an Exception Display the Exception Message test to see if an exception occurred Tell the system that you took care of the exception and it doesn’t need to crash

Unit 8 L2.2 In this exercise you will add a user to a database you create and to the membership database at the same time 1.Create a new table in your MIS3200 database with the following fields 1.User – nvarchar(100), primary key 2.UserFirstName – nvarchar(50) 3.UserLastName – nvarchar(50) 4.UserStreet- nvarchar(50)

U8L UserCity – nvarchar(50) 6.UserZip – nvarchar(10) 7.UserState – nchar(2) 8.UserPhone – nvarchar(50) 9.UserPasswordRequest – nvarchar(50) No fields should allow nulls except the Password field 2.Save the table as RegistrationData 3.Create a new web page – YourlastnameU8L22.aspx

U8L Add an H2 heading: “Creating customers and adding them to the ASP.NET membership database” 6.Under the heading add a message “If you are already registered with us, please click the login button above. If you would like to register, please click the Register link below.” 7.Add a TextBox to your page – Change its ID to txtCurrentUser – Set its Visible property = False 8.Add a DetailsView below the TextBox – Change the ID to dvRegistration You will see what we are going to do with this TextBox later.

U8L2.2-4 – Create a DataSource called sdsRegistration Select your new RegistrationData table Select all fields from the table, one at a time Click the Where… button – Set Column to User – Set Operator to = – Set Source to Control – Select ControlID = txtCurrentUser – Click Add and OK From the Configure the Select Statement window, click Advanced… – Click Generate Insert, Update, … and then click OK Click Next, then Finish

U8L Click Refresh Schema from the DetailsView’s smart menu 9.Set the width of dvRegistration to 300px 10.Click Auto Format and select an appropriate format 11.Click the Enable Editing and Inserting check boxes 12.Edit Fields – Change headings to be easier to read – i.e. First Name instead of FirstName

U8L2.2-6 – Convert all fields to Templates and then click OK – Click Edit Templates from the DetailsView’s smart menu Add required field validators to ALL edit and insert fields. – Set the Text of each to * and the ErrorMessage to something appropriate – Put all update validators in an Update validation group – Put all insert validators in an Insert validation group Add a Regular Expression Validator to the field (both insert and update templates) – Click the ValidationExpression property – Click … – Select Internet address

U8L2.2-7 Select the Password field (in my setup it is field #9) – Delete the TextBox from the EditItem Template – In the InsertItem Template Click after the TextBox (and validators if you have them in) Press Enter Add a new TextBox Add a required field validator to the new TextBox Add a compare validator to the new TextBox – Set the ControlToCompare to the first TextBox Set the TextMode of both password TextBoxes to Password Select the last field, the one with the new and edit buttons Add a ValidationSummary to the EditItem Template Set the ValidationGroup to Edit Set ShowMessageBox to True and ShowSummary to False Set the ValidationGroup of the Edit LinkButton to Edit

U8L2.2-8 Add a ValidationSummary to the InsertItem Template – Set the ValidationGroup to Insert – Set ShowMessageBox to True and ShowSummary to False – Set the ValidationGroup of the Insert LinkButton to Insert Select the EmptyData Template – Add a LinkButton to the template – Change its ID to lbRegister – Change its Text to Register – Change its CommandName to New Click End Template Editing

U8L We are going to save the user’s password in the membership database, not this table so we need to edit the data source – Select the registration DataSource – In the Properties window, select the InsertQuery and then click the … button – The Command and Parameter Editor should show an Insert statement something like this – Since we don’t want to save the Password we need to remove it from both the list of fields and the list of values as shown here

U8L After removing the password information the query should look like this You no longer need parameter so delete it from the Parameter list – Click on UserPasswordRequest – Click the delete button (the X) and then click OK Be sure that you delete the commas that were before the field name and the parameter name!

– Select UpdateQuery from the sdsRegistration properties – Delete the part of the query that updates the password and also delete the password parameter – When you are done click OK U8L2.2-11

U8L If you have done everything correctly you should be able to insert people into the Registration Database now so lets try it Run the page Click the Register button (link) Fix any errors you find and then test the validators – Try inserting a record with no data – Try inserting a record with an bad address – Try entering different passwords – Once you receive no errors and it looks like the data was entered Close the page Switch to the Database Explorer Select the RegistrationData table and Show Table Data Verify that the person you entered is there with no password

U8L Delete the user you just created 1.Click the right facing arrow on the left side of the table to select the row 2.Press the Delete key 3.Click on Yes 4.Close the data window

U8L Add a user to the membership database at the same time s/he is added to RegistrationData – First, we need a place to display a message so – Add a Label after sdsRegistration – Change the ID to lblMessage – Change the ForeColor to Red – Delete the Text – Select dvRegistration – Click the Events icon ( ) on the Properties window – Double-click next to ItemInserting This event occurs just before the data is sent to the database to be inserted

U8L – Add the following namespace at the top of the page … – Enter the code first seen on slide #6 – Event processing methods, in the ItemInserting method This is new and says to cancel the current operation, insert, if we were unable to insert the user in the membership system.

U8L – Switch back to the aspx page, select dvRegistration, click the Event icon and double click on ItemInserted This event happens after the database call and gives us a way to see if anything bad happened Add the code first show on slide #8 – Testing for an Exception

U8L Try running the page again – Add a new user – Do you get an error message? InvalidPassword may mean the password is too short DuplicateUserName means that user is already in the membership system – If successful, try to login as that user – Try to add the same user, the same , a second time Did you get an error message or a crash? – Does the error message hang around when it shouldn’t? Add a line that says to your Page_Load method.

U8L Allow the user to edit most of their information – Need a way to select the current user and display registration data in dvRegistration – Remember that the DetailsView select statement is linked to the contents of the TextBox, txtCurrentUser – We can determine the ID of the current user with a special object called the HttpContext. The following line gets the Name of the user and copies it into the txtCurrentUser textbox – Put this line of code in your Page_Load – Run the page, login with the user you created – You should see, and be able to edit, most of the Registration data

U8L Link you U8L22 page to your class page Copy everything back to ASPNET Run the application from ASPNET, starting with your Profile page to be sure it all works Post a link to you ASPNET homepage in the dropbox