Generally we use master page in our project and as it is a template we take common controls inside it. if we are using AJAX then we take update panel in master page. Or we can take update panel in our page individually. Now the problem is some controls are not work. Ex: FileUpload control doesnot work .
if (FileUpDigitalSignature.HasFile)
{
newCompInfo.UpDigitalSignature = Path.GetFileName(FileUpDigitalSignature.FileName);
FileUpArticle.SaveAs(Server.MapPath("~/images/") + newCompInfo.UpDigitalSignature);
StatusLabel.Text = "Upload status: File uploaded!";
}
so here we have to control the flow through a Trigger
#region Method to Add Trigger to UpdatePanel
public void AddTrigger()
{
UpdatePanelControlTrigger trigger = new PostBackTrigger();
trigger.ControlID = BtnAttachedSave .UniqueID;
UpdatePanel panel = (UpdatePanel)this.Page.Master.FindControl("UpdatePanel1");
panel.Triggers.Add(trigger);
}
#endregion
Now call this method in the page load event
protected void Page_Load(object sender, EventArgs e)
{
AddTrigger();
//or
ScriptManager.GetCurrent(this).RegisterPostBackControl(BtnAttachedSave);
if (IsPostBack == false)
{
}
}
After using this trigger the file upload control will work.
No comments:
Post a Comment