ASP.NET C# - POST Method - Pass information from a page to another

ASP.NET C# - POST Method - Pass information from a page to another

Gen Grievous

8 лет назад

23,828 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@anilgoswami1309
@anilgoswami1309 - 05.04.2022 07:47

not working on asp web page only form

Ответить
@mayurkadam5905
@mayurkadam5905 - 16.10.2020 19:39

protected void Page_Load(object sender, EventArgs e)
{
string Name = Request.Form["txtName"];
string Age = Request.Form["txtAge"];
string Email = Request.Form["txtEmail"];
string MobileNumber = Request.Form["txtMobileNumber"];
bool Gender =bool.Parse( Request.Form["RadioButton"]);
string City = Request.Form["DropDownList1"];
string Experience = Request.Form["RadioButtonList1"];
string ProblemResponse = Request.Form["txtProbResponse"];

lblName.Text = Name;
lblAge.Text = Age;
lblEmail.Text = Email;
lblMobileNumber.Text = MobileNumber;
if (Gender == true)
{
lblGender.Text = Convert.ToString( Request.Form["RadioButton1"]);
}
else if (Gender == true)
{
lblGender.Text=Convert.ToString(Request.Form["RadioButton2"]);
}
lblCity.Text = City;
lblExperience.Text = Experience;
lblProbResponse.Text = ProblemResponse;

}
This Code I have done on page load of Second Page.aspx & on First Page I had given "postbackUrl" to the buttton where it wiil be directed to second page. this is normal feed back form I'm creating but in gender it takes error. I also tried with session, Jquery but it doesn't give me perfect output.
I want to accomplish that when the Information is Given In one Should Be display on another Form on Label control.
And plz If u make the Video on It, also show me How to display the image on the control when we upload the file in upload control. as it is also getting problem .

protected void btnUpload_Click(object sender, EventArgs e)
{
btnVerification.Visible = true;

if (FileUpload1.HasFile)
{
string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName);

if (fileExtension.ToLower() != ".jpg" && fileExtension.ToLower() != ".png" && fileExtension.ToLower() != ".jpeg")
{
lblMessage.Text = "Only Files with .jpg, .png, .jpeg Extension are allowed";
lblMessage.ForeColor = System.Drawing.Color.DarkRed;
}
else
{
int fileSize = FileUpload1.PostedFile.ContentLength;
if (fileSize > 2097152)
{
lblMessage.Text = "Maximum file size (2MB) Exceeded";
lblMessage.ForeColor = System.Drawing.Color.DarkRed;
}
else
{
FileUpload1.SaveAs(Server.MapPath("~/Uploads/" + FileUpload1.FileName));
lblMessage.Text = "File Uploaded";
lblMessage.ForeColor = System.Drawing.Color.CadetBlue;
}
if (FileUpload1.HasFile)
{
Image1.ImageUrl = "~/Uploads/" + Image1;
}
else
{
lblMessage.Text = "No Image Uploaded";
lblMessage.ForeColor = System.Drawing.Color.YellowGreen;
}
}
}
else
{
lblMessage.Text = "Please Select a File to upload";
lblMessage.ForeColor = System.Drawing.Color.DarkRed;
}
}
this code is for upload control which i have done in it. where after file upload i want to display image but it doesn't show it to me.
so it will be better for me if u make a video.

Ответить
@mayurkadam5905
@mayurkadam5905 - 14.10.2020 16:23

how to pass radio button , check list and dropdown list controls with this Method can u will help me with the code. I had tried a Lot for it but I can't get the right way to do it.

Ответить
@danielperezaltabas2948
@danielperezaltabas2948 - 09.09.2019 18:29

I have an issue. Using this code: <form id="form1" runat="server">
<div>
<asp:TextBox ID="txtName" name="txtName" runat="server"></asp:TextBox>
<asp:TextBox ID="txtLastName" name="txtLastName" runat="server"></asp:TextBox>
<asp:Button ID="btnSend" runat="server" Text="Enviar" PostBackUrl="~/Second.aspx" />
</div>

</form>
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Request.RequestType);
Response.Write(Request.Form.Count);
Response.Write(Request.Form["txtName"]);
}
I'm getting RequestType GET
and Request.Form.Count 0
and no information on Request.Form["txtName"]
What can I do?

Ответить
@sajjadshakir2017
@sajjadshakir2017 - 03.04.2019 17:50

woow..

Ответить
@sridharramachandran3835
@sridharramachandran3835 - 01.11.2018 19:42

Clear and Quick at the same time! Thank You!

Ответить
@mirsankajovic7797
@mirsankajovic7797 - 12.09.2018 18:45

big thenksss

Ответить
@stefanitotokocopullo2739
@stefanitotokocopullo2739 - 06.07.2018 13:46

very helpfull. thank you a lot.keep going

Ответить
@andregomezmercado1183
@andregomezmercado1183 - 01.02.2017 21:14

Great video... the postBackUrl parameter also works with urls that arenot the our project right. a link?

Ответить
@Dashius77
@Dashius77 - 24.11.2016 21:30

Hello!, it was a really helpfull video, thanks a lot. Is it too much if you tell us how can we do to open a new tab insted of redirect "index.aspx" to "secondPage.aspx"?... Thanks again!.

Ответить
@rkcsp7
@rkcsp7 - 11.11.2016 20:51

Thank you for this. It was very helpful to me. I was racking my brain trying to figure out hoe to do a POST in VS2015 and didn't realise how simple it was until I saw your video. Thanks a million!

Ответить