4
When a postback occurs due to the TextChanged
event of the txtBasicValueGst18Per
TextBox, 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
}

3
Hello Sandeep,
you can use the update panel below and handle partial postback,
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" />
<asp:TextBox ID="txtBasicValueGst18Per" runat="server" onkeypress="return alertBox(this,event);" autocomplete="off"
TextMode="SingleLine" TabIndex="6" Width="150" MaxLength="10" AutoPostBack="true" CssClass="form-control" OnTextChanged="txtBasicValueGst18Per_TextChanged"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtBasicValueGst18Per" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
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
}

3
Can i do this using Update Pannel id yes thn how
3
It seems like you might be using .NET WebForms. Could you provide the fileName.aspx.cs file?
2
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