Presentation is loading. Please wait.

Presentation is loading. Please wait.

ASP.Net and HTML. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data.

Similar presentations


Presentation on theme: "ASP.Net and HTML. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data."— Presentation transcript:

1 ASP.Net and HTML

2 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" dim objConn as new OledbConnection(strConn) dim strSQL as string = "select * from customer;" dim objComm as new OledbCommand(strSQL,objConn) objConn.open() dim objDataReader as oledbDataReader objDataReader=objComm.executeReader() Response.Write(" ") do while objDataReader.Read()=true response.write(" ") response.write(" " & objdatareader("cid") & " ") response.write(" " & objdatareader("cname") & " ") response.write(" " & objdatareader("city") & " ") response.write(" " & objdatareader("rating") & " ") response.write(" " ) Loop Response.Write(" ") objDataReader.close end sub Creating a Table

3 Anchor Tag testAnchorTag Demo: ASPNet/ASPNETProdList.ASPX

4 Creating Links Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" Dim objConn As New OleDbConnection(strConn) Dim strSQL As String = "select * from product;" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() Do While objDataReader.Read() = True Response.Write(" " & objDataReader("description") & " ") Loop End Sub

5 Program that Response to links Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" Dim objConn As New OledbConnection(strConn) Dim strSQL As String = "select * from product where pid = '" Dim ProdID As String ProdID = Request.QueryString("pid") strSQL = strSQL & ProdID & "';" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() objDataReader.Read() Response.Write("PID = " & objDataReader("pid") & " ") Response.Write("Descrition = " & objDataReader("description") & " ") Response.Write("Price = " & objDataReader("price")) End Sub

6 Picture File Access: –OLE field –Picture file name: Relative reference Absolute reference Creating links to picture files Insert pictures in web page –IMG tag

7 Creating Links to Pictures (aspnetprodlistpic.aspx) sub Page_Load() dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" dim objConn as new OledbConnection(strConn) dim strSQL as string = "select PicID, PicDescription, PicPath from PictureTable;" dim objComm as new OledbCommand(strSQL,objConn) objConn.open() dim objDataReader as oledbDataReader objDataReader=objComm.executeReader() do while objDataReader.Read=True response.write (" " & objDataReader("PicDescription") & " ") loop objConn.close() end sub

8 Insert Pictures with IMG Tags sub Page_Load() response.write(" Available Pictures ") dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" dim objConn as new OledbConnection(strConn) dim strSQL as string = "select PicID, PicDescription, PicPath from PictureTable;" dim objComm as new OledbCommand(strSQL,objConn) objConn.open() dim objDataReader as oledbDataReader objDataReader=objComm.executeReader() do while objDataReader.Read=True response.write (" ") loop objConn.close() end sub Note: src=‘../images/

9 Creating Forms with Images ASPNet/AspNetProdListFormPic.Aspx

10 <% dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" dim objConn as new OledbConnection(strConn) dim strSQL as string = "select * from product;" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() Do While objDataReader.Read() = True %> <% response.write ("PID = " & objDataReader("pid") & " ") response.write ("Descrition = " & objDataReader("description") & " ") response.write ("Price = " & objDataReader("price")) %> Qty: " width="65" height="90"> <% loop %>

11 ASP.Net Repeater Control The Repeater is a basic templated data-bound list typically used to display records from a: –Database table –Collections such as arraylist containing objects. It has no built-in layout or styles, so you must explicitly declare all HTML layout, formatting, and style tags within the control's templates. The Repeater has no built-in editing support. The Repeater uses template to control formatting and data binding.

12 Repeater Control’s Templates Five types of templates: –HeaderTemplate, ItemTemplate, AlternatingItemTemplate, SeparatorTemplate, FooterTemplate Note 1: A Repeater binds its ItemTemplate and AlternatingItemTemplate to a DataSource. The HeaderTemplate, FooterTemplate, and SeparatorTemplate are not data-bound. Note 2: At a minimum, every Repeater must define an ItemTemplate.

13 Repeater Example Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" Dim objConn As New OledbConnection(strConn) Dim strSQL As String = "select * from customer;" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() Repeater1.DataSource = objDataReader Repeater1.DataBind() End Sub

14 Note: Databinding tag

15 Creating a Table Using Repeater To create a table using templates, include the begin table tag in the HeaderTemplate, a single table row tag and in the ItemTemplate, and the end table tag ( ) in the FooterTemplate.

16 Creating a Table Using Repeater (DataSource can be a Readaer or Dataset) Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" Dim objConn As New OleDbConnection(strConn) Dim strSQL As String = "select * from customer;" Dim objComm As New OleDbCommand(strSQL, objConn) Dim Results As String objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() Repeater1.DataSource = objDataReader Repeater1.DataBind() objDataReader.Close() or 'OleDbDataAdapter1.Fill(DataSet21) 'Repeater1.DataSource = DataSet21 'Repeater1.DataMember = "customer" 'Repeater1.DataBind()

17 Creating a Table Using Repeater CID Cname City Rating

18 Repeater Binding To An ArrayList myCust.getData("C01") myCust.getOrders("C01") Repeater1.DataSource = myCust.orders Repeater1.DataBind()

19 Binding to Object’s Properties

20 Creating Links Using Repeater Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\salesDB.mdb" Dim objConn As New OledbConnection(strConn) Dim strSQL As String = "select * from product;" Dim objComm As New OleDbCommand(strSQL, objConn) objConn.Open() Dim objDataReader As OleDbDataReader objDataReader = objComm.ExecuteReader() Repeater1.DataSource = objDataReader Repeater1.DataBind() objConn.Close() End Sub

21 '>


Download ppt "ASP.Net and HTML. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data."

Similar presentations


Ads by Google