Question

In: Computer Science

Create an ASP.NET page and add ScriptManager and UpdatePanel controls. Next, add a SqlDataSource and DetailsView...

Create an ASP.NET page and add ScriptManager and UpdatePanel controls. Next, add a SqlDataSource and DetailsView control within the UpdatePanel and configure them so that the visitor can.

add new records to the Books table. add two Label Web controls to this page—one outside the UpdatePanel and the other within the UpdatePanel. Have the Label Text properties assigned to the current date and time on each page load. When testing the page, note that when the page is first visited, the two Labels' values match, but when a new record is added through the DetailsView control, the Label within the UpdatePanel is updated, but one outside the UpdatePanel is no

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new asp.net web application with C# is created using Visual Studio 2017 with name "Demo_BooksApplication".This application contains a web page with name "AddBook.aspx".Below are the files associated with AddBook.aspx

1.AddBook.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddBook.aspx.cs" Inherits="Demo_BooksApplication.AddBook" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%-- title for web page --%>
<title>Book Demo</title>
</head>
<body>
<form id="form1" runat="server">
<%--ScriptManager control --%>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div>
<%-- UpdatePanel --%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%-- label to display date and time --%>
<asp:Label ID="lblWithinUpdatePanel" runat="server"></asp:Label>
<%-- details view --%>
<asp:DetailsView ID="DetailsView1" runat="server" AllowPaging="True" AutoGenerateInsertButton="True" AutoGenerateRows="False" DataKeyNames="BookID" DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="BookID" HeaderText="BookID" InsertVisible="False" ReadOnly="True" SortExpression="BookID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Author" HeaderText="Author" SortExpression="Author" />
<asp:BoundField DataField="YearPublished" HeaderText="YearPublished" SortExpression="YearPublished" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="LastReadOn" HeaderText="LastReadOn" SortExpression="LastReadOn" />
<asp:BoundField DataField="PageCount" HeaderText="PageCount" SortExpression="PageCount" />
</Fields>
</asp:DetailsView>
<%-- sql data source --%>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BookDBConnectionString %>" DeleteCommand="DELETE FROM [Books] WHERE [BookID] = @BookID" InsertCommand="INSERT INTO [Books] ([Title], [Author], [YearPublished], [Price], [LastReadOn], [PageCount]) VALUES (@Title, @Author, @YearPublished, @Price, @LastReadOn, @PageCount)" SelectCommand="SELECT * FROM [Books]" UpdateCommand="UPDATE [Books] SET [Title] = @Title, [Author] = @Author, [YearPublished] = @YearPublished, [Price] = @Price, [LastReadOn] = @LastReadOn, [PageCount] = @PageCount WHERE [BookID] = @BookID">
<DeleteParameters>
<asp:Parameter Name="BookID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="YearPublished" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="LastReadOn" Type="DateTime" />
<asp:Parameter Name="PageCount" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="YearPublished" Type="Int32" />
<asp:Parameter Name="Price" Type="Decimal" />
<asp:Parameter Name="LastReadOn" Type="DateTime" />
<asp:Parameter Name="PageCount" Type="Int32" />
<asp:Parameter Name="BookID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
  
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br />
<br />
<%-- label to display date and time --%>
<asp:Label ID="lbloutsideUpdatePanel" runat="server"></asp:Label>
</form>
</body>
</html>

2.AddBook.aspx.cs

//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//application namespace
namespace Demo_BooksApplication
{
public partial class AddBook : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//display date and time on label that is inside update panel
lblWithinUpdatePanel.Text ="Inside Update Panel : "+ DateTime.Now.ToLongTimeString();
//display date and time on label that is outside update panel
lbloutsideUpdatePanel.Text = "Outside Update Panel : "+DateTime.Now.ToLongTimeString();
}
}
}

======================================================

Output : Run application using F5 and will get the screen as shown below

Screen 1 :AddBook.aspx

Screen 2 :Click on New and will get the screen as shown below

Screen 3 :Screen when timing change in the label inside update panel

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

For your final project, you are to create a two-page web application of your choice. ASP.NET...
For your final project, you are to create a two-page web application of your choice. ASP.NET : C# You must include the following items: At least 5 different standard server controls At least 2 validation controls At least 1 navigation control ~ one must navigate back and forth to each page One session state element Upon completion of your two-page web application, you will provide a two page report describing the functions of the web application as well as each...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression,...
C# & ASP.NET Create a console application that prompts the user to enter a regular expression, and then prompts the user to enter some input and compare the two for a match until the user presses Esc: The default regular expression checks for at least one digit. Enter a regular expression (or press ENTER to use the default): ^[a- z]+$ Enter some input: apples apples matches ^[a-z]+$? True Press ESC to end or any key to try again. Enter a...
Create an ASP.NET Core MVC solution, edit the main view to contain an HTML form that...
Create an ASP.NET Core MVC solution, edit the main view to contain an HTML form that asks for first name, last name, and email address. The form should also have a submit button, though the submit button doesn't have to do anything yet. looking for an HTML mockup inside an ASP.NET Core MVC Solution.
Create a page with jQuery. 1. Add "IMG.jpg" with size WIDTH="200" HEIGHT="60", give an id. 2....
Create a page with jQuery. 1. Add "IMG.jpg" with size WIDTH="200" HEIGHT="60", give an id. 2. Use mouseenter(), width(), and height() to resize the picture to 800 by 230. 3. Use mouseleave, width(), and height() to resize the picture to 200 by 60.
Create a second page of your diagram (in the same file) and on it create a...
Create a second page of your diagram (in the same file) and on it create a Diagram 0 DFD of CSIES using the following information: The CSIES has within it the following processes and data store: PROCESS PAYMENT. This process interfaces with both the student and InsureRight Insurance Company. It receives the payment from the student and sends the payment to the InsureRight Insurance Company. It receives a receipt from the insurance company and sends a receipt to the student....
1 -​Create the code to generate a default web page. The contents of this page should...
1 -​Create the code to generate a default web page. The contents of this page should be Your​​Name, right justified
Create following webpage in HTML : 1. Login Page This is the first page the user...
Create following webpage in HTML : 1. Login Page This is the first page the user should see. The user can login, signup, or continue as a guest. Your task is to implement the following features: a) Signup form This form should collect the information required for creating a new account on your movie database website. At the least, it should collect an email address, username, avatar image/graphic, first name, last name, and a password. You can ask for more...
Step 2: Create Stored Procedures to Add/Update/Delete an entity table Create a script to create a...
Step 2: Create Stored Procedures to Add/Update/Delete an entity table Create a script to create a table named ProjectBilling which will have the following columns: • projectBillID char(6) : A 6 character unique identifier (numbers and letters) • TransAmount decimal(16,9) : The amount of the transaction • TransDesc varchar(255): A description of the transaction • TransDate datetime: The date of the transaction • projectID char(4):The Id of the project • accountMgr char(8):The employee who manages the bill ledger Include this...
For the scenario on the next page, write a paper that explains the following to a...
For the scenario on the next page, write a paper that explains the following to a prospective client: A) Formulate both null and alternative hypotheses for the client, and explain why the hypotheses need to be directional or non-directional. B) Determine what statistical test should be used to analyze the data. C) Summarize all information used to determine the correct statistical test (e.g., number of groups, type of data collected, independent or repeated measures) D) Provide a sample size and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT