Hi harindaw,
In order to stop post back you need to make ajax call and save the data in database.
Or you can save the data in session and reuse to set the value in textboxes after postback.
Check this example. Now please take its reference and correct your code.
HTML
<asp:TextBox runat="server" ID="txtName" />
<asp:Button Text="Save" runat="server" OnClick="OnSave" />
<asp:FileUpload ID="fuUpload" runat="server" />
<asp:Button Text="Upload" runat="server" OnClick="OnUpload" />
Code
C#
protected void OnSave(object sender, EventArgs e)
{
Detail detail = new Detail();
// Set TextBoxes values.
detail.Name = txtName.Text.Trim();
// Your insert code in database.
// Save in Session.
Session["Data"] = detail;
}
protected void OnUpload(object sender, EventArgs e)
{
if (Session["Data"] != null)
{
Detail detail = (Detail)Session["Data"];
txtName.Text = detail.Name;
// File upload code.
// Clear the session.
Session["Data"] = null;
txtName.Text = "";
}
}
public class Detail
{
public string Name { get; set; }
// other properties.
}
VB.Net
Protected Sub OnSave(ByVal sender As Object, ByVal e As EventArgs)
Dim detail As Detail = New Detail()
detail.Name = txtName.Text.Trim()
Session("Data") = detail
End Sub
Protected Sub OnUpload(ByVal sender As Object, ByVal e As EventArgs)
If Session("Data") IsNot Nothing Then
Dim detail As Detail = CType(Session("Data"), Detail)
txtName.Text = detail.Name
Session("Data") = Nothing
txtName.Text = ""
End If
End Sub
Public Class Detail
Public Property Name As String
End Class