| |

VerySource

 Forgot password?
 Register
Search
View: 729|Reply: 5

Questions about request.form

[Copy link]

2

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-12 20:00:02
| Show all posts |Read mode
I have two pages:
1. <body>
    <form id = "form1" runat = "server">
    <div>
        <asp: Label ID = "Label1" runat = "server" Text = "Your name is:"> </ asp: Label>
        <asp: TextBox ID = "name" runat = "server"> </ asp: TextBox> <br />
        <asp: Label ID = "Label2" runat = "server" Text = "Your age is:"> </ asp: Label>
        <asp: TextBox ID = "age" runat = "server"> </ asp: TextBox> <br />
        <asp: Button ID = "Button1" runat = "server" Text = "Submit" OnClick = "Button1_Click" />
        <br />
        <br />
        <br />
    </ div>
    </ form>
</ body>
2,
 protected void Page_Load (object sender, EventArgs e)
    {
        string recive_id, recive_age;
        recive_id = Request.Form ["id"];
        recive_age = Request.Form ["age"];
        Response.Write ("My name =" + recive_id + "<br>" + "My age =" + recive_age + "<br>");
        // 3\
        Response.Write ("You are using" + Request.RequestType + "Method to pass data");
        
    }

How can I get their value? Please master
I
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 Japan

Post time: 2020-4-10 14:30:02
| Show all posts
recive_id = name.Text;
Reply

Use magic Report

2

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-10 20:45:01
| Show all posts
string valus = Page.Request.Form.Get ("a"); // This is the control name = "a"
        Page.Response.Write ("The value of the text you entered is:" + valus);
Reply

Use magic Report

1

Threads

6

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-4-11 00:30:01
| Show all posts
Agree upstairs. I also just learned. . Haha
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-4-13 12:15:01
| Show all posts
protected void Page_Load (object sender, EventArgs e)
    {
        string recive_id, recive_age;
        recive_id = Request.Form ["name"]; // TextBox id of name is name
        recive_age = Request.Form ["age"]; // This is true.
        Response.Write ("My name =" + recive_id + "<br>" + "My age =" + recive_age + "<br>");
        // 3\
        Response.Write ("You are using" + Request.RequestType + "Method to pass data");
        
    }


If you send it directly to this page, it is most convenient to use recive_id = name.Text;

reference:
<% @ PreviousPageType VirtualPath = "~ / SourcePage.aspx"%>

if (Page.PreviousPage! = null)
{
    TextBox SourceTextBox =
        (TextBox) Page.PreviousPage.FindControl ("TextBox1");
    if (SourceTextBox! = null)
    {
        Label1.Text = SourceTextBox.Text;
    }
}
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-4-13 13:00:01
| Show all posts
protected void Page_Load (object sender, EventArgs e)
    {
        string recive_id, recive_age;
        recive_id = Request.Form ["id"]; // Wrong here, Form ["name"]
        recive_age = Request.Form ["age"]; // Yes, here is the ID value of the control that needs to be accessed
        Response.Write ("My name =" + recive_id + "<br>" + "My age =" + recive_age + "<br>");
        // 3\
        Response.Write ("You are using" + Request.RequestType + "Method to pass data");
        
    }

If you post to this page, use recive_id = name.Text; more convenient.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list