Webform (built-in object-response and redirect, querystring value, Repeater pruning)

Source: Internet
Author: User

first, built-in objects
AResponse-Response Request Object
1. Definition: The Response object is used to dynamically respond to client referrals, control the information sent to the user, and dynamically generate responses. The response object only provides a data collection cookie that is used to write cookie values on the client. If the specified cookie does not exist, it is created. If it does exist, it will be updated automatically. The results are returned to the client browser.
2. Methods
(1)Redirect
Usage: Response.Redirect ("url")
The role is to redirect the server end multiplicity to another Web page
(2) Write
Function: Send to the client a variety of data that the browser can handle, including: HTML code, scripting, etc.
Usage: Response.Write ("") input string is displayed in interface, input <script>alert (') </script> popup dialog box
TwoRequest-Get Request Object
request["Key"]-the string type is returned by default
To get the value passed in, the request object interacts with the client, collects the client's form, Cookies, hyperlinks, or collects server-side environment variables.
Second, cross-page transmission value
QueryString-Address bar data stitching
Stitching in the Address bar? Key=value Key is any character, value is the values to be passed,? Cannot have spaces between = and =
Multiple data transfer values in the Address bar continue stitching &key=value
void Button1_Click (object sender, EventArgs e)
{
String path = "Default2.aspx?aaa=" + TextBox1.Text + "&bbb=" + TextBox2.Text;

Response.Redirect (path);//or using Server.Transfer (path);
}
Receive a worthy interface:
Label1.Text = request["AAA"];
Label1.Text + = "," + request["BBB"];

Iii. Repeater and pruning

Add a column to the ItemTemplate to change and delete the hyperlink

<TD>                         <aID= "Lian"onclick= "Return del ()"href= "delete.aspx?id=<% #Eval ("Code ")%>The > Delete</a>&nbsp;                        <aTarget= "_blank"href= "update.aspx?up=<% #Eval ("Code ")%>"> Modify</a>                    </TD>

(i) Delete

1. Write the deletion method, the main page is Default.aspx, delete the page is delete.aspx

2. Add JS script to determine if you want to delete

<script>     function  del () {         var j = document.getElementById ("Lian");          var ok = Confirm ("Are you sure you want to delete?") ");          if false ) {             returnfalse;         }          return true ;     };         </script>

3. Execute the Delete command in the Page_Load of Delete and refresh the page

  // take out        The primary key value you want to delete string Code = request["ID"];         // the primary key value is passed to the method for deletion.    BOOL New studentdata (). Delete (Code);         // Skip to transfer display page        after delete complete if (b)        {            Response.Redirect ("default.aspx");  }

(ii) Amendment

1. Constructs the modification interface, and carries on the verification and the data point

2. Present the original data to the page

3. Perform the modification, close the Modify page after the modification, and refresh the main interface

protected voidButton1_Click (Objectsender, EventArgs e) {Student s=NewStudent (); S.code=Xuehao_text.text; S.name=Name_text.text; S.sex=Convert.toboolean (RadioButtonList1.SelectedValue); stringTime = Year_dr.selectedvalue +"-"+ MOUTH_DR. SelectedValue +"-"+Day_dr.    SelectedValue; S.birthday=Convert.todatetime (time); S.subjectcode=Subject_dw.    SelectedValue; S.nation=Nation_dw.selectedvalue; BOOLb =Newstudentdata (). Update (s); if(b) {Response.Write ("<script>"); Response.Write ("alert (' modified successfully! ');"); Response.Write ("window.opener.location.href= ' default.aspx ';"); Response.Write ("window.close ();"); Response.Write ("</script>"); }}

Webform (built-in object-response and redirect, querystring value, Repeater pruning)

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.