Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi There i am trying to update my xml file through a editor in asp.net but does not updates.
It works fine on Local and Development server.but not working on production server.

I am Pasting my code Down here help me with it.


This i Did because as soon as i click on Update button of my CorporateCharities.aspx page i was getting thrown to login.aspx page so the below code i wrote for page load of login page.

private void WriteToItemDataset(string ItemNo)
{
    DataSet ds = new DataSet();
    DataTable dt = new DataTable("Items");
 
if (Session["dtItemData"] != null)
{
    dt = (DataTable)Session["dtItemData"];
}
if (ItemNo != string.Empty)
{
    foreach (DataRow row in dt.Rows)
    {
        if (!Convert.ToBoolean(row["DeletedFlag"])&& ItemNo == Convert.ToString(row["ItemNo"]))
        {
            row["ItemDescription"] = Editor3.Value;
            dt.AcceptChanges();
            break;
        }
    }
 
 DataView dv = dt.DefaultView;
dv.Sort = "DeletedFlag,ItemNo";
Session["dtItemData"] = dt;
string Filepath = Server.MapPath("~/CorporateCharities_Content.xml");
 
if (File.Exists(Filepath))
{
   dt.WriteXml(Filepath,true);
   this.errorMessageHtmlCell.Attributes.Add("style", "color:Green");
   this.errorMessageHtmlCell.InnerText = "Record(s) saved successfully.";
}
else
{
   this.errorMessageHtmlCell.Attributes.Add("style", "color:Red");
   this.errorMessageHtmlCell.InnerText = "File Not Found.";
}


protected void Submit_Click(object sender, EventArgs e)
        {
               string ItemNo = Convert.ToString(Session["EditValue"]);
                this.WriteToItemDataset(ItemNo);
                this.errorMessageHtmlCell.InnerText = "Record(s) saved successfully."; //+ ItemNo;
                this.errorMessageHtmlCell.Attributes.Add("style", "color:Green");
                BindDataLIst();
                Editor3.Value = "";
                trMsgContent.Visible = true;
                trEditorMsg.Visible = false;                
                       
        }
Posted
Updated 5-Dec-11 1:12am
v2

1 solution

Check permission for this XML file on server.It's read only i think
 
Share this answer
 
Comments
Amod Kumar Jaiswal 5-Dec-11 22:29pm    
how can i check it on server.
plz help me.
Anuj Banka 6-Dec-11 0:07am    
Just go the folder where you have your file.And just right click and check if its readonly then uncheck the check box.And check permission for IIS users Also

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900