Create
The account administration would be quite useless if you couldn't create a new account. Figure 12-5 shows the AdmAcntCreate Web page that is designed for this task. n Adjnhiiitrai amp rj . Uidliui Crcatt Tr'j i l- L -L-I K in n i. ' v.Li MI M I Figure 12-5 The AdmAcntCreate Web page Looking at Figure 12-5, you should spot something you haven't used before the multiselect list box. The list box stores all the possible roles in the system that a user can have. Listing 12-21 shows the design code...
Reading an XML File Using XmlTextReader
Open the code for ReadXML in the edit window. Nothing should be new to you. For ReadXML, you need to add the XML namespace. The code is just like adding any other namespace using System.Web.UI.HtmlControls using System.Xml From here on, all the code you are going to add will be found within the IsPostBack if statement in the Page_Load method. The first thing you need to do is open up the XML stream in an XmlTextReader so that it can be read. The method is quite straightforward. Basically, pass...
Programmatically Updating a webconfig File Setupsetup2cs
The updateConfigWeb method handles all the gory details of updating the web.config file. It takes as parameters all the values that will be placed in the web.config file. public void UpdateConfigWeb String database, String datasource, String userid, String password, String timeout It then opens the web.config file, loads it into an XmlDocument for processing, and closes it so that it may be opened later for writing. XmlDocument doc new XmlDocument The first thing it does is look for the lt...
The Setupsetup4cs Codebehind
Setup4 still requires a little bit of work before it is free to display the cheery message of successful completion. It needs to set the lt appSettings gt add setup attribute value in the web.config file to true. By setting it to true, the admin.aspx which was discussed at the beginning of the chapter knows that it can now run CMS.NET's administration system. The code for the Page_Load method see Listing 10-22 is virtually the same as the updateConfigWeb method found in setup2.cs. First, you...
The AccountAuthentication Method
ASP.NET provides a built-in facility to handle authentications. First, you add a lt credentials gt element to your web.config file, as follows lt credentials passwordFormat None gt lt user name Admin password CMS.Net gt lt user name sfraser password Agr8pswd gt lt credentials gt Then you call the following tbPassword.Text It is even possible to encrypt the passwords in the web.config file. Encryption is covered later in this chapter. The problem with this method of authentication is that you...



