Guide:
Through an example, how to use the Page.isPostBack property to replace the RS (Remote scripting) technology in the ASP to implement communication with the server side without refreshing the current page.
-------------------------------------------------- ------------------------------
An application of the page.ispostback property can be used to save users
Information, I will introduce another use of it, which is the RS (Remote scripting) technology in the ASP.
As for the basic concepts and usage of RS, I have already introduced many in the ASP version. Its main advantage is not to refresh.
In the case of the current page, communicate with the server side. But because of its underlying, Java technology is used, so it uses
It is still more cumbersome, and I will introduce how to use Page.ispostback in ASP to replace RS technology.
According to my habits, I like to explain the problem with specific examples, so this time I use a simple instance to explain.
problem. In this example, a products.aspx program will be used, which mainly has two server-side controls (Server-Side
Control), this is the new control programming method introduced in ASP , one is a drop-down box control - 'Mudcategories',
The other is a list box control - 'MudProducts'. This example will demonstrate that the content in the list box will follow the contents in the pull box.
The change changes, in order to make it easy, I will implement the database examples from SQL Server.
The products.aspx code is as follows:
<% @ Import namespace = "system.data"%>
<% @ Import namespace = "system.data.ado"%>
SUB Page_Load (SourceObj As Object, EVEARG As Eventargs)
IF not page.ispostback then
Dim Mudcommand as adodatasetcommand
DIM MudConnection as adoconnection
DIM DSET AS New DataSet
DIM STRSQL AS STRING
DIM Connstr As String
strsql = "Select CategoryId, CategoryName from Categories"
Connstr = "provider = sqloledb; data source = TEST; Initial catalog = northwind; user ID = sa; password =;"
MudConnection = New Adoconnection (connStr)
Mudcommand = New AdodatasetCommand (strsql, mudconnection)
Mudcommand.FillDataSet (dset, "categories")
Mudcategories.DataSource = dset.tables ("categories"). DefaultView
Mudcategories.DATABIND () END IF
End Sub
Sub DisplayProducts (Source As Object, EVEARG AS Eventargs)
Dim Mudcommand as adodatasetcommand
DIM MudConnection as adoconnection
DIM DSET AS New DataSet
DIM STRSQL AS STRING
DIM Connstr As String
Connstr = "provider = sqloledb; data source = TEST; Initial catalog = northwind; user ID = sa; password =;"
strsql = "Select Productid, ProductName from Products"
Strsql = strsql & "where categoryid =" & mudcategories.selectedItem.Value
MudConnection = New Adoconnection (connStr)
Mudcommand = New AdodatasetCommand (strsql, mudconnection)
Mudcommand.FillDataSet (Dset, "Products")
MudProducts.DataSource = dset.tables ("products"). DefaultView
MudProducts.DATABIND ()
End Sub
script>