Reputation: 323
I send data in this way:
<form method="post" enctype="text/plain action="Func">
And I have a function:
protected void Func(object sender, EventArgs e)
How Can I get data which I sent?
Upvotes: 0
Views: 64
Reputation: 16512
To get data of a post you can do that
Request.Form["nameOfyourControl"]
Upvotes: 0
Reputation: 12966
From the signature of your method it looks like you're using WebForms. Is this right? If so, in WebForms you don't write the <form>
tag like this, it's easier to create a new ASPX page (Web Form) and use the default. Everything on the page goes in one form. To "get the data", you just access properties on your page's controls, e.g. myTextBox.Text
.
If you're coming from PHP and this all sounds a bit weird, you may want to be using ASP.Net MVC. In which case, it's generally easier to use an HTML Helper method for the form, something like:
using(Html.BeginForm())
{
...
}
But then the signature of your method is all wrong, you'd be better defining a View Model class, and having something like:
[HttpPost]
public void Func(ViewModel postedModelData)
{
...
}
Upvotes: 2