ImageVerifierCode 换一换
格式:PPT , 页数:50 ,大小:74KB ,
资源ID:376741      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-376741.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Introduction to VB Internet Tools.ppt)为本站会员(boatfragile160)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Introduction to VB Internet Tools.ppt

1、Introduction to VB.Net Internet Tools,Downloading Internet Resources,Download the HTML from a web page and display it in a text box. System.URI A class for expressing a Uniform Resource Identifier. System.Net.WebRequest Makes a request to a Uniform Resource Identifier. WebResponse Provides a respons

2、e from a Uniform Resource Identifier. Demo: MyBrowser/GetWebPage,Imports System.IO Imports System.Net Imports System.Text Private Sub BtnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGo.ClickDim URI As New Uri(txtURL.Text)Dim request As WebRequest = WebRequest.Creat

3、e(URI)Dim response As WebResponse = request.GetResponseDim stream As Stream = response.GetResponseStreamDim readStream As New StreamReader(stream)Dim webData As String = readStream.ReadToEndstream.Close()readStream.Close()txtData.Text = webData End sub,Change Downloaded Page,For example, use strings

4、 Replace method to change page content. webData = webData.Replace(“Chao“, “You“),Using the WebClient Class,This class wraps the Request and Response classes. Methods: DownloadData: Returns a byte array from an Internet address. DownloadFile: Save a downloaded file. OpenRead: Returns a stream from an

5、 Internet address.,UTFEncoding Class,This class encodes Unicode characters using UCS Transformation Format, 8-bit form (UTF-8). This encoding supports all Unicode character Method: GetString Decodes the specified byte array into a string.,WebClient/Download,Dim wc As New WebClient()Dim utf8 As New U

6、TF8Encoding()Dim webData As StringwebData = utf8.GetString(wc.DownloadData(txtURL.Text)txtData.Text = webData,WebClient/DownloadFile,Dim wc As New WebClient() wc.DownloadFile(txtURL.Text, “c:testDownLoad.txt“),WebClient/OpenRead,Dim wc As New WebClient()Dim stream As Streamstream = wc.OpenRead(txtUR

7、L.Text)Dim readStream As New StreamReader(stream)Dim webData As String = readStream.ReadToEndtxtData.Text = webData,Hosting Internet Explorer in Windows Forms,Internet Explorer COM control Right click Tool Box Windows Form tab and select Customize ToolBox Select COM Component tab, and Scroll down to

8、 select Microsoft Web Browser.,Internet Explorer COM control,Events DownLoadComplete DownLoadBegin Methods: Navigate Dim HomeURL As String = “http:/dchaolaptop“Private Sub MyBrowser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadIE.Navigate(HomeURL)End Sub Goback

9、, GoForward Stop Refresh2 GoHome, GoSearch,Introduction to Web Form,Web Form vs HTML Form,HTML Form: A web page that contains one or more HTML form controls such as textbox, checkbox, dropdown list, and button inside an HTML tag. Web Form: A web page that contains:ASP.NET server controls, and/or HTM

10、L form controls inside a tag. ASP.NET code that produces dynamic content to be displayed within the web form.,ASP.NET Server Controls, ASP:,Intrinsic Controls: These controls correspond to their HTML counterparts. Ex. Textbox, listbox, button, etc. Data-Centric Controls: Controls used for binding an

11、d displaying data from a data source, such as the DataGrid control. Rich Controls: Such as Calendar, AdRotator. Validation Controls: Such as RequiredFieldValidator. Namespace:System.Web.UI.Webcontrols,Web Server,Default directory C:InetPubwwwroot Computer lab: Zip drive dchao Default home page Defau

12、lt.aspx, default.asp, default.htm,Web Project,File/New/ ASP.Net Application Website folder Web form: Webform.aspx Design view and HTML view WebForm.Aspx.VB CodeBehind,Web Data Form,Web Data Form Wizard: Project/Add Web Form/Data Form Wizard Web Form with Server Explorer or Data Tools. Data binding O

13、leDbDataAdapter1.Fill(Ds21) DataGrid1.DataBind(),Use Data Reader to Create a DropDown List,Demo: WebForm/WebForm2 Update rating for selected customer,Introduction to ASP.Net,ASP.NET,ASP.NET is a server-side technology for creating dynamic web pages. ASP.NET allows you to use a selection of full prog

14、ramming languages. The default language is VB .NET. ASP.NET files have a .aspx extension.,ASP.NET in the .NET Framework,1. The client requests a web page. 2. The web server locates the page. 3. If the page is an ASP.NET page, it is sent to the Common Language Runtime for compilation and execution. 4

15、. The HTML produced by the CLR is returned to the browser.,Benefits of Server-Side Technology,Browser compatibility: Every browser reads HTML. Protection of source code. Controls are server-side objects with properties, methods and events. Separating code from content. Embedded code CodeBehind Data

16、entered into form fields is preserved in View State.,Elements of an ASP.Net Page,Directives Code blocks ASP.NET controls HTML tags and text. Server-side include directives,Directives,A directive controls how an ASP.Net page is compiled. Page directives: Specify default language, enable tracing and d

17、ebugging for a page. , Imports name spaces To process Access database, we need to import:,Inserting ASP.NET Code into Web Pages,Place ASP.NET code between and with a RUNAT attribute.Your scriptInline Code Block: ASP code is placed between . The time is now The time is now “=“ is shorthand for respon

18、se.write Server-side comments:CodeBehind,Demo: TineNow.aspx,The time is now The time is now good afternoon“) end if %,ASP.NET Object Model,Client,Server,Request Object,Response Object,Server Object,Session Object,Application Object,ASP.NET Request Object,When a page is requested, much information is

19、 passed along with the request, such as the URL, queryString, and data from a form. The request object allows you to get the information passed along with the request. It is created from the System.Web.HttpRequest class.,FORM Tag,Form attribute: Action: Specify the URL of a program on a server or an

20、 email address to which a forms data will be submitted. Method: Get: the forms data is appended to the URL specified by the Action attribute as a QueryString. Post: A prefered method for database processing. Forms data is sent separately from the URL. Name: Forms name,QueryString,A QueryString is a

21、set of name=value pairs appended to a target URL. It can be used to pass information from one webpage to another. Example: ,Request Object Collections,QueryString http:/ cid = Request.queryString(“CustID”) cName=Request.queryString(“CustName”) Form A form with two text boxes:CustID, CustName cid = R

22、equest.Form(“CustID”) cName=Request.Form(“CustName”) Cookies,ASP.NET Response Object,This object allows you to send information back to client. It is created from the System.Web.HttpResponse class. Properties: Cookies (a collection) Methods: Response.Write Response.Redirect (“URL”) Demo: testReqForm

23、.htm, testReqForm.aspx,Postback,Postback is the process by which the browser posts information back to the server telling the server to handle the event, the server does so and sends the resulting HTML back to the browser. Page.ISPostBack property. IF Not Page.ISPostBack Then This is the first time

24、the page is loaded. AutoPostBack property Button true DropDown list, textbox, radiobutton, checkbox: False,FrontPage/VS.Net Demo,wwwRoot/Webform Webform1: Copy from VS.Net toFrontPage Handles OnClick Webform5: AutoPostBack Page.IsPostBack Use a Buttons onClick event instead of Listboxs selectedIndex

25、Changed event. Copy to FrontPage.,VB/WebForm/FrontPage,Demo: VB: MyBrowser/GetWebPage WebForm: RichControl FrontPage:ASPNet/GetPageChange.aspx,Bind the DataReader to a Server Control,DataGrid: dim objDataReader as oledbDataReader objDataReader=objComm.executeReader() dgCustomer.datasource=objDataRea

26、der dgCustomer.DataBind() The Datagrid is defined as:Demo: CommandReadCust.ASPX,Web Service,XML Web Service Web services are classes that are stored on the web which can instantiate and use in both Windows and Web applications.,Creating a Web Service Using a Text Editor,WebService directive:Import n

27、amespaces: imports System.Web.Services imports System Define the web service class. Add WebMethod attribute to the function declaration. Note: Web service file extension is ASMX,A Web Service Example ASPET/TestWebService.ASMX, imports System.Web.Services imports System imports System.Data imports Sy

28、stem.Data.Oledb Public Class CustomerInfopublic Function GetCname(ByVal CID as String) as Stringdim strConn as string =“Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:sales2k.mdb“dim objConn as new OledbConnection(strConn)dim strSQL as string = “select * from customer where CID = “ “dim objComm as

29、 new OledbCommand(strSQL,objConn)dim Results as stringobjConn.open()dim objDataReader as oledbDataReaderobjDataReader=objComm.executeReader()objDataReader.read()return objDataReader(“Cname“)end function,Creating a Web Service Using VS,New Project/ASP.Net Web Service,Web Service Description Language

30、(WSDL),A WSDL file is an XML document containing a complete description of the web service. It shows a web services name, methods, and parameter types. Help page: After entering web services URL, a help page is displayed. You can click the Service Description link to see the WSDL file.,HTTP,HTTP Req

31、uest: Request line: Method Get, Post Header Body HTTP Response: Respons line: HTTP version and status code Header Body,Invoking a Web Service with HTTP,Http Get: http:/dchaolaptop/aspnet/testwebservice.asmx/GetRating?cid=1 Http Post: Use the Action attribute to call the function. Http-SOAP: Use Http

32、s Post method to send an XML document in Https body section.Demo: Help page,Simple Object Access Protocol SOAP,SOAP Request and Response message: Envelop: An envelop element surrounds the message. It is the root element of a SOAP XML document. Body: Request: Contains the method call name and paramet

33、er names and values. Response: Contains the results returned by the method.,Consuming Web Services from a Windows Application,Add a web reference to the web service. Declare a web service class variable. Dim myWebService As New dchaolaptop.CustomerInfo()Demo: UseWebService,Universal Description, Dis

34、covery, and Integration (UDDI),A directory service for web services. http:/uddi.org,Consuming Web Services from a Web Application,Creating a web service proxy class: A local representation of the web service. Steps to creating a proxy class: Use the Wsdl.exe tool to generate the source code file for

35、 the proxy class. Compile the source code file into a DLL file. Copy the DLL file to the applications Bin folder.,Use the Wsdl.Exe Tool to Generate the Source Code File,Issue the wsdl.exe command at the Visual Studio command prompt:Start/Programs/microsoft VS .Net/VS .Net Tools/ VS .Net Command prom

36、ptThe following command example create a CustomerInfo.vb file for the testwebservice.asmx web service. wsdl.exe /l:vb http:/dchaolaptop/aspnet/testwebservice.asmx?wsdl,Compile the Source Code File Into a DLL File,The command below create a CustomerInfo.dll Vbc /t:library /r:system.dll,system.web.services.dll,system.xml.dll CustomerInfo.vb, sub CallService(s as object, e as eventArgs) dim myProxy as new CustomerInfo lblCname.text=myProxy.GetCname(txtCID.text) lblRating.text=myProxy.GetRating(txtCID.text) end subEnter CID: Demo: testProxy.aspx,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1