Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45.

Similar presentations


Presentation on theme: "Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45."— Presentation transcript:

1 Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45

2 Server Side Languages There are several choices for server side programming languages for web content, but PHP and.NET currently have the largest market shares.NET has between 15-30%, including: msn.com Microsoft.com nytimes.com chase.com Walmart.com bankofamerica.com

3 .NET.NET applications are generally written in Visual Studio We are going to use Visual Studio 2013 to build some simple web pages In general, when building.NET web applications, we need to chose between C# and Visual Basic(VB) For this course, we are going to use C#

4 Visual Studio 2013 When opening VS2013, choose “Visual C#” from the dropdown of pre-defined Development Settings If you chose “General” on accident, you can go to Tools -> Import and Export Settings -> Reset all settings -> just reset settings -> Choose Visual C# and click Finish New Project… Templates -> Visual C# -> Web Choose a name for your application Choose a save path (I recommend your P drive) On the next screen choose the Empty template

5 .NET Master Page When building CI sites, we used a “template” view to set up our headers/footers/etc In.NET, we use what is called a “Master Page” Right click on your project name in the Solution Explorer window Choose Add -> New Item… Scroll to the bottom of the list and choose “Web Forms Master Page” In CI, we loaded views inside of views, in the Master Page, we need to set up Content Placeholders

6 .NET Master Page The master page is not a page that can be actually rendered on the website, but rather just a template for other pages The ContentPlaceHolder tags produce regions where child pages can insert content into the overall template These regions are not dynamically maintained in the child pages, so you want to try and get them as close to correct before you start building pages as possible to keep from needing to re-touch all your pages later

7 .NET Master Page Next, lets create a folder called Styles and Scripts and add a style sheet and JavaScript file to each We can add these to the master page by dragging them into the correct position Go ahead and add jQuery to the master page as well

8 .NET - Notes Top line on each page Look at the three files that make up a page form tag runat=“server” Adding/Removing/Modifying ContentPlaceHolders Layered Templates

9 .NET Web Page Now we can create our first web page From the New menu, create a Web Form with Master Page and name it Default.aspx In.NET applications, the home page is often called Default.aspx, just like in html it is index.html or php it is index.php The ContentPlaceHolders from earlier are the only regions we can add content to the Default page Adding content outside of these tags will throw error messages

10 .NET Web Page Let’s add a little bit of content to this page and test to see if everything is set up correctly by pressing “F5” Menu: Debug->Start Debugging Once we confirm that is working, we can close the browser window We also need to tell Visual Studio to Stop Debugging so we can edit pages again

11 .NET Web Page Let’s build a simple form by dragging some controls from the toolbox to the page Again, lets test to ensure this is loading on the page the way we expect Now let’s set the button to get the text out of textbox and write it into the label To do this, let’s start by click on “Split” at the bottom which should show the code and a mock up of the form

12 .NET Web Page Now, if we double click on the button, Visual Studio will automatically create a function that will execute when the button is clicked If we go back to Default.aspx, we will see that an attribute was added to the button control OnClick=“MyButton_Click” Back in the code file – Default.aspx.cs, let’s write the code to get the content from our textbox into the label For this, we just need to use dot notation, and all the controls are already objects

13 .NET Code File protected void MyButton_Click(object sender, EventArgs e) { MyLabel.Text = MyTextbox.Text; } Now we can test the page again, and see if that works You should notice that C# syntax is relatively similar to Java This is because they both share similar roots in C

14 .NET Validation.NET validation uses client side validation through jQuery followed by Server Side validation To make the client side validation function properly, we need to include the jQuery library in the page (which we did on the master page) Next we need to register the jQuery script, which we will do inside of a Global Application Class file, which we can create from the New menu

15 .NET Global Inside of the Application_Start method, we need to tell the application what version of jQuery to use, and where it is located string JQueryVer = "1.11.3"; ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition { Path = "https://ajax.googleapis.com/ajax/libs/jquery/" + JQueryVer + "jquery.min.js", DebugPath = "https://ajax.googleapis.com/ajax/libs/jquery/" + JQueryVer + "jquery.min.js", CdnPath = "https://ajax.googleapis.com/ajax/libs/jquery/" + JQueryVer + "jquery.min.js", CdnDebugPath = "https://ajax.googleapis.com/ajax/libs/jquery/" + JQueryVer + "jquery.min.js", CdnSupportsSecureConnection = true, LoadSuccessExpression = "window.jQuery" });

16 .NET Validation Now, go back to Default.aspx and find the Validation section in the toolbox RequiredFieldValidator CompareValidator RangeValidator CustomValidator Add the server side check to the button click Page.IsValid

17 .NET Events Click on one of the controls we added to the form In the bottom right corner, the properties window has a lightning bolt, this is the events tab When you double click on a control, it chooses a default event to create a function for, from the events list, you can easily create functions for other events

18 Lab 6 – C#/MSSQL Due: Nov 5 Create a simple web form in C#.NET Minimum: 2 Text Fields, 1 Drop Down (include a blank option), 2 Radio Buttons grouped together, 3 Checkboxes, 1 Submit Button Create a MSSQL DB and Table to store the form submissions Ensure the form is properly validating all fields before inserting the data into the DB Output an HTML table containing the values in your DB table

19 Next Time Next time we will look at MSSQL and working with it from C#.NET Reminders: Lab 5 (AJAX) is due on Thursday (Oct 29 th ) Lab 6 (C#) is due on Nov 5 th Project 2 is due on Nov 5 th Term Project is due on Dec 10 th


Download ppt "Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN 6710 - Section A – TR 9:30-10:45 CRN 10570 – Section B – TR 5:30-6:45."

Similar presentations


Ads by Google