Question 2

(a) What do you mean by structured error handling? Create VB .Net console application to accept 10 numbers from user and find its average. Also handle IndexOutOfRangeException.

Module Module1
Sub Main()
Dim counter, sum As Integer
Dim average As Double
Dim numberArray(10) As Integer
Console.writeLine("Enter the Numbers : ")
sum = 0
For counter = 0 To 9
Console.write("Number " & (counter + 1) & " : ")
numberArray(counter) = Console.ReadLine()
sum += numberArray(counter)
Next counter
average = sum / 10
Console.writeLine("Average of 10 Numbers is : " & average)
Console.writeLine("Handle IndexOutOfRangeException")
Try
sum = numberArray(15)
Console.WriteLine("No Exception occured!!!")
Catch ioore As IndexOutOfRangeException
Console.WriteLine("Exception : Index is Out Of Range")
Finally
Console.WriteLine("Finally Block Executed!!")
Console.ReadLine()
End Try
End Sub
End Module

(b) What is namespace? Explain it with its advantages. Create VB.Net console application to implement user defined namespace. Also give code to import it in another application.

' User Defined NameSpace

Namespace namespaceExample 
public class classExample
public sub printMessage()
Console.WriteLine("This is the TestExample namespace!")
End sub
End class
End Namespace ' Importing NameSpace into Application Imports namespaceAlias = dotNetTechnology.namespaceExample.classExample
Module Module1
Sub Main()
namespaceAlias.printMessage()
End Sub
End Module

(b) What is inheritance? Create VB .Net console application to define person class and derive student and employee from it to demonstrate inheritance.

Module Module1
Public Class person
Public personName As String
Public phoneNumber As String
Public Sub showPersonData()
Console.writeLine("Name : " & personName)
Console.writeLine("CPI : " & phoneNumber)
End Sub
End Class
Public Class student
Inherits person
Public rollNumber As Integer
Public cpi As Double
Public Sub showStudentData()
Console.WriteLine("Roll Number : " & rollNumber)
Console.WriteLine("CPI : " & cpi)
End Sub
End Class
Public Class employee
Inherits person
Public empId As Integer
Public salary As Double
Public Sub showEmployeeData()
Console.WriteLine("Employee ID : " & empId)
Console.WriteLine("Salary : " & salary)
End Sub
End Class
Sub Main()
Dim studentObj As student = New student()
studentObj.personName = "Jaydip Panchal"
studentObj.phoneNumber = 7878314409
studentObj.rollNumber = 61
studentObj.cpi = 7.28
Console.writeLine("Student Data : ")
studentObj.showPersonData()
studentObj.showStudentData()
Dim employeeObj As employee = New employee()
employeeObj.personName = "Pratik Patel"
employeeObj.phoneNumber = 9429389214
employeeObj.empId = 50
employeeObj.salary = 25000
Console.writeLine("Employee Data : ")
employeeObj.showPersonData()
employeeObj.showEmployeeData()
Console.ReadLine()
End Sub
End Module

Question 3

(a) What is Property? Explain read only, write only and read write property with suitable example.

'  Read write property Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace readWritePropertyExample
{
public class student
{
private String studentName = "";
public string sName
{
get
{
return studentName;
}
set
{
studentName = value;
}
}
}
public class readWriteProperty
{
public static void Main(String[] args)
{
Console.WriteLine("Read Write Property Simple Example");
student studentObject = new student();
// Set sName Property
studentObject.sName = "Jaydip";
// Get sName Property
Console.WrileLine("Student Name : " + studentObject.sName);
}
}
}

'  Read Only property Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace readOnlyPropertyExample
{
public class student
{
private String studentName = "";
public student(String nameValue)
{
studentName = namevalue;
}
public string sName
{
get
{
return studentName;
}
}
}
public class readProperty
{
public static void Main(String[] args)
{
Console.WriteLine("Read Only Property Simple Example");
student studentObject = new student("Arpan");
// Get sName Property
Console.WrileLine("Student Name : " + studentObject.sName);
}
}
}

'  Write Only property Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace writeOnlyPropertyExample
{
public class student
{
private String studentName = "";
public string sName
{
set
{
studentName = value;
}
}
public String getStudentName()
{
return studentName;
}
}
public class writeProperty
{
public static void Main(String[] args)
{
Console.WriteLine("Write Only Property Simple Example");
student studentObject = new student();
// Set sName Property
studentObject.sName = "Pratik";
Console.WrileLine("Student Name : " + studentObject.getStudentName());
}
}
}
(b) What is delegate? What is its real time usage? Give C# code to demonstrate delegate.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public delegate double doubleDelegate(double w,double h);
namespace delegateSimpleExample
{
public class delegateClass
{
public static double getArea(double w,double h)
{
return w*h*0.5;
}
}
public class delegateSimpleExampleDemo
{
public static void Main(String[] args)
{
Console.WriteLine("C# code to demonstrate delegate");
doubleDelegate delegateObject = new doubleDelegate(delegateClass.getArea);
Console.WrileLine("Area of Triangle is : " + delegateObject(15,20));
Console.ReadLine();
}
}
}

Question 4

(a) Differentiate ASP and ASP.Net. Explain Hyperlink and Image controls with example.

<!DOCTYPE html>
<html>
<body>
<form runat="server">
<!-- Image controls in ASP.NET -->
<asp:Image runat="server" id="image1" ImageUrl="sample.jpg" ImageAlign="Left" AlternateText="Sample Image" />
<!-- Hyperlink controls in ASP.NET -->
<asp:HyperLink runat="server" ID="hyperlink1" NavigateUrl="http://www.help2engg.com" Text="Engineering Social Network" Target="_blank" />
</form>
</body>
</html>

(b) What is Theme? Differentiate css and skin file. Give ASP.Net code to define theme and also give code to apply it in webpage.

To define Theme you have to create first page theme and then you have to create skin file.

Steps for creating Page Themes
1. In the Solution Explorer, right-click on your web site name and hover to Add ASP.NET then click Themes.
2. Now you will see an App_Themes folder.
3. Then create Newfolder of ThemeFolder in the App_Themes .
Steps for creating Skin file
4. Right-click on the ThemeFolder and click on Add New Item.
5. Then, you will see the Add New Item dialog box, you have to click on Skin File.
6. Type the name of the .skin file in the textbox.
Now you can add following .skin file code to created .skin file
ASP.Net code to define theme : <asp:label runat="server" Width="100px" Height="30px" Font-Size="Large" Font-Bold="true" ForeColor="#666666" BackColor="#FFFFFF" BorderColor="#FFFFFF" />
<asp:button runat="server" ForeColor="#000000" BackColor="#000000" BorderColor="#FFFFFF" Font-Italic="true"/>

<!-- ASP.Net code to apply it in webpage. -->

<%@ Page Language="C#" Theme="ThemeFolder" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>ASP.Net code to define theme and how to apply it in Web Page</title>
</head>
<body>
<font runat="server">
<asp:label runat="server" ID="lable1" Text="Download GTU Dot Net Technology Paper Solution"></asp:label>
<asp:button runat="server" Text="Download"></asp:button>
</font>
</body>
</html>

(a) What is Master Page? Give ASP.Net code to demonstrate the usage of nested master page.

Master Page Code : 


<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div id="header">
<h1>Master Page </h1>
</div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder>
</form>
</body>
</html>

Nested Master Page Code :


<%@ Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="childMaster.master.cs" Inherits="childemaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Label ID="Label1" runat="server" BackColor="#666666" ForeColor="#00FF66" BorderColor="#9933CC" BorderWidth="3px" Text="Nested Master Page Code"></asp:Label>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</asp:Content>

Implementing Nested Master Page : 


<%@ Page Title="" Language="C#" MasterPageFile="~/childMaster.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">ASP.Net code to demonstrate the usage of Nested Master Page<br />
<asp:Button ID="btn1" runat="server" BackColor="#000000" Font-Italic="true" Font-Size="Small" ForeColor="#FFFFFF" Text="Download Code" />
</asp:Content>

(b) What do you mean by data bound controls? Explain DataList control with code to display list of students with enrolmentno and branch.

<!--Default web form-->
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<asp:DataList ID="datalist1" runat="server" DataKeyField="enrollmentNumber" DataSourceID="databaseGTUStudent">
<ItemStyle BackColor="#000000" ForeColor="#FFFFFF" />
<ItemTemplate>
Enrollment Number<asp:Label ID="lblEnrollmentNumber" runat="server" Text='<%# Eval("enrollNumber") %>' />
<br />
Branch<asp:Label ID="lblBranch" runat="server"
Text='<%# Eval("branch") %>' />
<br />
</ItemTemplate>
<SelectedItemStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="#000000" />
</asp:DataList>
<asp:SqlDataSource ID="databaseGTUStudent" runat="server"
ConnectionString="<%$ ConnectionStrings:studentDataConnectionb %>"

SelectCommand="SELECT [enrollNumber], [branch], FROM [student]">
</asp:SqlDataSource>
</form>
</body>
</html>

<!--Web.config -->
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="studentDataConnectiona" connectionString="Data Source=.;Initial Catalog=northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="studentDataConnectionb" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=studentData;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
</configuration>

Question 5

(a) What is state management? Explain Application state and Viewstate with suitable example.

Application State Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btn_Click(object sender, System.EventArgs e)
{
int counter = 0;
if(Application["counter"] !=null)
{
counter = (int)Application["counter"];
}
counter++;
Application["counter"] = counter;
label.Text = "Counter : " + counter.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Application state example in ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="label" runat="server" Font-Size="Large" ForeColor="#000000" Text="Counter : 0"> </asp:Label>
<br />
<asp:Button ID="btn" runat="server" Text="Increment Counter" OnClick="btn_Click" />
</div>
</form>
</body>
</html>

View State Example

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
if(ViewState["counter"] !=null)
{
counter = (int)ViewState["counter"];
label.Text = "Counter : " + counter.ToString();
}
protected void btn_Click(object sender, System.EventArgs e)
{
if(ViewState["counter"] !=null)
{
counter = (int)ViewState["counter"];
}
else
{
int counter = 0;
}
counter++;
ViewState["counter"] = counter;
label.Text = "Counter : " + counter.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>View state example in ASP.NET</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="label" runat="server" Font-Size="Large" ForeColor="#000000"> </asp:Label>
<br />
<asp:Button ID="btn" runat="server" Text="Increment Counter" OnClick="btn_Click" />
</div>
</form>
</body>
</html>

(a) What is webservice? Create a web service to find area of circle. Also give code to consume it.

Web Service CS File


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebServiceSimpleExample : System.Web.Services.WebService
{
public WebServiceSimpleExample () {}
[WebMethod]
public double areaOfCircle(double radius)
{
double area;
area = 3.14*radius*radius;
return area;
}
}

Default Page ASPX File: 



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div> <b>Calculate Simple Interest using
the Web Service</b> <br />
<asp:Label ID="label" runat="server" Text="Radius"
Width="100px"></asp:Label>
<br />
<asp:TextBox ID="txt"
runat="server"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="Calculate Area Of Circle"
Width="220px" onclick="btn_Click" />
<br />
<asp:Label ID="result" runat="server" Width="100px"></asp:Label>
<br />
</div>
</form>
</body>
</html>

Default CS File :


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e){}
protected void btn_Click(object sender, EventArgs e)
{
localhost.WebServiceSimpleExample ws = new localhost.WebServiceSimpleExample();
ws.EnableDecompression = true;
Double area = 0;
if(txtl.Text == "")
{
result.Text = "Please Enter Radius of Circle";
}
else
{
area = ws.areaOfCircle(System.Convert.ToDouble(txt.Text));
result.Text = area.ToString();
}
}
}

Web Service Simple Example CS File :


<%@ WebService Language="C#" CodeBehind="~/Code/WebServiceSimpleExample.cs" Class="WebService" %>
    

Web Config File : 


<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<appSettings>
<add key="localhost.WebServiceSimpleExample" value="http://localhost:2244/WebServiceSimpleExample/WebServiceSimpleExample.asmx"/>
</appSettings>
</configuration>

(b) What is AJAX? Give ASP.Net code to use UpdatePanel control.

Default Page ASPX File :


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ASP.Net code to use UpdatePanel control</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate> Number of refreshes:
<asp:TextBox ID="text" runat="server" ReadOnly="true" Text="0"> </asp:TextBox>
<asp:Button Text="Increment Counter" ID="btn" runat="server" onclick="btn_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

Default CS File

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e){}
protected void btnRefresh_Click(object sender, EventArgs e)
{
int incCount = Int32.Parse(text.Text);
incCount++;
text.Text = incCount.ToString();
}
}

Make Comments..!!


Ansari Md Tahir
thanks...and so much.... ... i want PHP..materials..pls send me...
'my email id : " ansari.tahir.7it@gmail.com "
Like · Comment ·
Arpan Patel
W3schools website is good for beginner of the PHP
Like · 1 ·
Hiranshi Prajapati
Tx 4solution
Like · Comment ·
Abhishek Patel and Er Chandresh Prajapati like this
Patel Siddharth
thanks.................
Like · Comment ·
Joydip Panchal and Admin like this
Jigisha Parmar
thank u very very much for the solution
Like · Comment ·
Urvashi Jadav and 5 other like this
Janak Padia
i like it
Like ·
Ruchika Patel
thansk....
Like · Comment ·
Joydip Panchal and Er Chandresh Prajapati like this
Harsh Trivedi
thank u:-))
Like · Comment ·
Shilpesh Solanky and Joydip Panchal like this
Darshita Pathak
thank you
If you have 2nd Remedial 's Paper Solution then Please Upload it Or Mail It on sgpathak112@gmail.com
Like · Comment ·
Shilpesh Solanky likes this
Mihir Patel
thankyou,,,
Like · Comment ·
Joydip Panchal and Shaily Shah like this
Shaily Shah
thanks a lot!!!
Like · Comment ·
Urvashi Jadav and 5 other like this
Shaily Shah
@chetan prajapati sry i m nt joining!!!
Like ·
Download Android App