-----------------------------------
-----------------------------------
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Jun 6, 2024, 6:00 AM EDT
When a postback occurs due to the
TextChangedevent of thetxtBasicValueGst18PerTextBox, the entire page lifecycle is executed again, which includes re-rendering the page controls and resetting their values to their original states.protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Check if file data is stored in session state if (Session["FileData"] != null) { // Retrieve file data from session state and reassign it to FileUpload control var fileData = (FileData)Session["FileData"]; fuquationFile1.FileName = fileData.FileName; // Assign other file data properties as needed } } } protected void txtBasicValueGst18Per_TextChanged(object sender, EventArgs e) { // Your event handler logic here // Store file data in session state var fileData = new FileData { FileName = fuquationFile1.FileName, // Set other file data properties as needed }; Session["FileData"] = fileData; } // Define a class to represent file data public class FileData { public string FileName { get; set; } // Add other file data properties as needed }Sandeep KumarRank #1,642 · 937 reputationPosted Jun 5, 2024, 6:14 AM EDT
Any One help me
Dwarkesh VajjalaRank #1,975 · 740 reputationPosted Jun 5, 2024, 7:26 AM EDT
It seems like you might be using .NET WebForms. Could you provide the fileName.aspx.cs file?
Sandeep KumarRank #1,642 · 937 reputationPosted Jun 6, 2024, 6:15 AM EDT
Can i do this using Update Pannel id yes thn how
Sandeep KumarRank #1,642 · 937 reputationPosted Jun 6, 2024, 5:07 AM EDT
Simple I have Web form page (
aspx) In Existing Page I have added file upload control where there were many textbox changedevent and dropdown onselectindexchanged event fired but when Fileupload attaching a file then file getting cleared when textchanged event fired
Please Help m,e
Jignesh KumarRank #91 · 22.9K reputationPosted Jun 6, 2024, 11:17 PM EDT
Hello Sandeep,
you can use the update panel below and handle partial postback,
Servcer side as below,
protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); FileUpload1.PostedFile.SaveAs(Server.MapPath("~/Uploads/") + fileName); // Additional logic for handling the uploaded file } } protected void txtBasicValueGst18Per_TextChanged(object sender, EventArgs e) { // Handle text changed event }