Asp. The framework of RS (Remote scripting) technology replacing ASP in net

Source: Internet
Author: User
asp.net guide:
An example illustrates how to use the Page.IsPostBack property to replace the RS (Remote scripting) technology in ASP to communicate with the server without refreshing the current page.
--------------------------------------------------------------------------------
An application of the Page.IsPostBack property that can be used to save user input
Information, I'll introduce another use of it, which is to replace the RS (Remote scripting) technology in ASP.
As for the basic concept and usage of Rs I have a lot of introduction in ASP version, its main advantage is not to refresh
Communicates with the server side in the case of the current page. But because it is using Java technology at the bottom, it uses
Up or appear more cumbersome, I will introduce in the asp+ how to use Page.IsPostBack to replace RS technology.
According to my custom, I like to use specific examples to explain the problem, so this time using a simple example to illustrate
Problem. In the following example, a products.aspx program is used, which has two server-side controls (server-side
Control), which is the new controls introduced in Asp+, one is a drop-down box control-' mudcategories ',
The other is a list box control--' mudproducts '. This example will show that the contents of the list box will follow the contents of the Drop-down box
Changes, and for the convenience of everyone to reproduce, I will use the database examples from SQL Server to implement.

The Products.aspx code is as follows:

<%@ Import namespace= "System.Data"%>
<%@ Import namespace= "System.Data.ADO"%>
<script language= "VB" runat= "Server" >
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>
<form name= "Mudform" runat= "Server" >

Product Catalog:
<asp:dropdownlist id= "mudcategories" runat= "Server" datatextfield= "CategoryName" datavaluefield= "CategoryID" Autopostback= "true" onselectedindexchanged= "Displayproducts"/>
Products: <asp:listbox id= "mudproducts" selectionmode= "multiple" datavaluefield= "ProductID" datatextfield= "runat=" Server/>

From the example program can be seen, which is obviously using the server-side control of the dropdown box onchange event with AutoPostBack and
Page.IsPostBack attribute can be very simple and clear to achieve the previous in the ASP in the cumbersome RS implementation method.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.