Danh mục

Professional VB 2005 - 2006 phần 7

Số trang: 110      Loại file: pdf      Dung lượng: 6.83 MB      Lượt xem: 20      Lượt tải: 0    
tailieu_vip

Xem trước 10 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Bây giờ chạy các ứng dụng. Các bố trí ban đầu sẽ được tương tự như các thiết kế bố trí thời gian. Tuy nhiên, nếu bạn thay đổi kích thước các hình thức khoảng một nửa chiều rộng ban đầu của nó, cách bố trí của các hộp văn bản sẽ thay đổi.
Nội dung trích xuất từ tài liệu:
Professional VB 2005 - 2006 phần 7 Chapter 17 Cross-Page Posting The way in which Active Server Pages 2.0/3.0 (also called classic ASP) worked was that values fromimpo PDF Merge and posted Unregistered Version were usually steps in a process that the end user forms were usually Split to other pages. These pages - http://www.simpopdf.com worked through. With the introduction of ASP.NET on the other hand, pages in this environment posted back results to themselves in a step called a postback. One of the biggest requests of Web developers in the ASP.NET world has been the ability to do postbacks not only to the page from whence the values originated, but also the ability to do postbacks to other pages within the application. This new feature is something that has been provided with the release of ASP.NET 2.0. Cross-page posting (as it is referred) is an easy functionality to achieve now. It gives you the ability to post page values from one page (Page1.aspx) to an entirely different page (Page2.aspx). Normally, when posting to the same page (as with ASP.NET 1.0/1.1), you could capture the postback in a postback event as shown here: If Page.IsPostBack Then ‘ do work here End If Now, let’s take a look at Page1.aspx and see how you accomplish cross-page posting with ASP.NET 2.0. Protected Sub Button1_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Label1.Text = “Your name is: “ & TextBox1.Text & “” & _ “Your appointment is on: “ & Calendar1.SelectedDate.ToLongDateString() End Sub Cross-Page Posting What is your name? When is your appointment? 628 ASP.NET 2.0 Advanced Features impo PDF Merge and Split Unregistered Version - http://www.simpopdf.com With Page1.aspx, you can see that there is nothing really different about this page — except for the Button2 server control. This page contains a new attribute which you will find with the Button, ImageButton, and LinkButton controls — the PostBackUrl attribute. The value of this attribute points to the location of the file that this page should post to. In this case, the PostBackUrl attribute states that this page should post to Page2.aspx. You can see that this is the only thing needed on the Page1.aspx to cause it to post back to another page. As for Button1, you can see that this is a simple button which will cause the page to post back to itself. This is nothing new as this has been the case even in ASP.NET 1.x. You can see the event handler for this postback in the OnClick attribute within the Button1 control. Pressing this button will cause the page to post back to itself and to populate the Label1 control that is at the bottom of the page. Clicking on the second button, though, will post to the second page, which is shown here: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Dim pp_TextBox1 As TextBox Dim pp_Calendar1 As Calendar pp_TextBox1 = CType(PreviousPage.FindControl(“TextBox1”), TextBox) pp_Calendar1 = CType(PreviousPage.FindControl(“Calendar1”), Calendar) Label1.Text = “Your name is: “ & pp_TextBox1.Text & “” & _ “Your appointment is on: “ & _ pp_Calendar1.SelectedDate.ToLongDateString() End Sub Second Page In this page, the first step is that in the Page_Load event, instances of both the TextBox and Calendar controls are created. From here, these instances are populated with the values of these controls on the previous page (Page1.aspx) by using the PreviousPage.FindControl() method. The S ...

Tài liệu được xem nhiều: