DD Class12
From IAMMediaWiki Create Change
Contents |
[edit] Boyce-Codd Normal form
- needs to be in 3NF
http://en.wikipedia.org/wiki/Boyce-Codd_normal_form
[edit] Fourth Normal Form
- needs to be in BCNF
Fourth Normal Form
- separates independent multi-valued facts stored in one table into separate tables.
http://en.wikipedia.org/wiki/Fourth_normal_form
[edit] Fifth Normal Form
- needs to be in 4NF
Fifth Normal Form
- breaks out data redundancy that is not covered by any of the previous normal forms.
http://en.wikipedia.org/wiki/Fifth_normal_form
More normal forms
http://en.wikipedia.org/wiki/Database_normalization
[edit] Mappath
Server.Mappath
upload permissions
[edit] Upload a File
http uploader
Add executionTimeout and maxRequestLength to the web.config so that large uploads will not fail.
<configuration> <system.web> <!-- httpRuntime Attributes: executionTimeout="[seconds]" - time in seconds before request is automatically timed out maxRequestLength="[KBytes]" - KBytes size of maximum request length to accept useFullyQualifiedRedirectUrl="[true|false]" - Fully qualifiy the URL for client redirects minFreeThreads="[count]" - minimum number of free thread to allow execution of new requests minLocalRequestFreeThreads="[count]" - minimum number of free thread to allow execution of new local requests appRequestQueueLimit="[count]" - maximum number of requests queued for the application enableKernelOutputCache="[true|false]" - enable the http.sys cache on IIS6 and higher - default is true enableVersionHeader="[true|false]" - outputs X-AspNet-Version header with each request --> <httpRuntime executionTimeout="1200" maxRequestLength="65536" /> </system.web> </configuration>
multipart form
<form enctype="multipart/form-data" runat="server"> <tr> <td>Select file to upload:</td> <td> <input id="myfile" type="file" runat="server"></td> </tr> <tr> <td> <input type=button id="btnUploadTheFile" value="Upload" OnServerClick="btnUploadTheFile_Click" runat="server" /> </td> </tr> </form>
Parse the multipart form and save the file msdn library. System.Web.HtmlInputFile.PostedFile Property
void btnUploadTheFile_Click(object Source, EventArgs evArgs) { //Path to save file string strBaseLocation = ""; if (null != myfile.PostedFile) { // Get the HTTP posted file instance (to simplify the code) HttpPostedFile postedfile = myfile.PostedFile; // Get the filename string filename = new System.IO.FileInfo(postedfile.FileName).Name; string filesize = postedfile.ContentLength.ToString(); try { myfile.PostedFile.SaveAs(strBaseLocation+filename); txtOutput.InnerHtml = "File " + strBaseLocation + filename + " uploaded successfully"; } catch (Exception e) { txtOutput.InnerHtml = "Error saving " + strBaseLocation + filename + " "+ e.ToString(); } //Do some other stuff //maybe like send an email to let admin know file was uploaded } }
http://iam.colum.edu/oop/classsource/class14/up.aspx [up.aspx - source] [web.config - source]
[edit] Modifications
Uniqie filename
// Get the filename string filename = new System.IO.FileInfo(postedfile.FileName).Name; string strUniqueDate = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Ticks.ToString() ; filename = strUniqueDate + "_" + filename;
Add to database instead of sending email
[edit] Aspx Templates and Reuse
The template page
http://iam.colum.edu/dd/classsource/class11/UserControls/TemplateNoControls.aspx - source
[edit] Include Files
<table border="1"> <tr> <td colspan ="3" align="center"><div align="center" class="Title">This is the header</div></td> </tr> <tr> <td valign="top"> <!-- #include virtual="incs/col1.aspx" --> </td> <td valign="top"><div align="center" class="SectionTitle">Main Column</div> <p>Content Content Content</a> </td> <td valign="top"> <!-- #include virtual="incs/col3.aspx" --> </td> </tr> <tr> <td colspan="3" align ="center"> <!-- #include virtual="incs/foot.aspx" --> </td> </tr> </table>
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/incs/col1.aspx
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/incs/col3.aspx
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/incs/foot.aspx
[edit] User Controls
User Controls are user defined controls that are reusable. They have and event model similar to the page class. They have an isolated scope. The page class can send data to user controls via user defined atributes.
User Controls must be registered via a Register Directive (this can also be done via web.config for an entire site)
<%@ Register TagPrefix="DataDesign" TagName="Col1" Src="controls/col1.ascx" %>
the control can then be used by adding the custom tag to the page
<DataDesign:Col1 id="ucCol1" runat="server" />
http://iam.colum.edu/dd/classsource/class11/UserControls/TemplateUserControls.aspx
Controls
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/controls/col1.ascx
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/controls/col3.ascx
http://iam.colum.edu/dd/gbrowser.php?file=/classsource/class11/UserControls/controls/foot.ascx
