Asp. NET rookie Road of response small example

Source: Internet
Author: User

background
  • I am an ASP., temporarily began to learn ASP. NET, in this record I personally knock code, not much reference value, please see the pots of friends for me to support me a bit, thank you.
  • Response.Write Redirect
  • Response.Write () is used to output a string or array of characters to the client, and Response.Redirect is used for redirection, which shows the transfer URL data, which requires two interactions with the client.
  • The next example is to redirect the input information to another interface and display it.
  • Create a new web window redirect.aspx, enter
    <formID= "Form1"runat= "Server">        <Div>            <Table>                <TR>                    <TD>User name:</TD>                    <TD><Asp:textboxrunat= "Server"ID= "Txtname"/></TD>                </TR>                <TR>                    <TD>Gender:</TD>                    <TD><Asp:textboxrunat= "Server"ID= "Txtsex"/></TD>                </TR>                <TR>                    <TD>                        &nbsp;                    </TD>                    <TD><Asp:buttonrunat= "Server"ID= "Btnregister"Text= "Register"OnClick= "Btnregister_click" /></TD>                </TR>            </Table>        </Div>    </form>
  • Add a Btnregister_click event in the Redirect.aspx.cs file
    protected voidBtnregister_click (Objectsender, EventArgs e) {        stringstrname = This. txtName.Text; stringSex =""; if(Txtsex.text = ="male") {Sex="Mr."; }        Else if(Txtsex.text = ="female") {Sex="Lady"; } Response.Redirect ("index.aspx?sname="+ strname +"&sex="+sex); }
  • Then create a new Wen form index.aspx and write it in the background
  • protected void Page_Load (object  sender, EventArgs e)    {        string name = request.querystring["  sName"];         string sex = request.querystring["sex"];        Response.Write (Name  "    + sex +" Welcome registration " );    }

  • Run effect for output registered personal information
  • Asp. NET rookie Road of response small example

    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.