Back at it

  •  11-02-2003, 9:05 PM

    Back at it

    A while back I asked about editing a literal using cute editor and saving the changes. I assumed that this was the main purpose of the tool. The samples allow you to edit the text and make changes, and when you update they are displayed, however - as soon as the page is re-loaded the text that is in the page_load event is redisplayed. I don't see the point in that. I had expected that the update would possibly update the HTML, with the new formatting.

    I recieved  one response about this - suggesting that I would have to save the edited text to a database. Is this the only option? I wrote code to attempt that. I pull text from a SQL DB then change it in the editor and save. In order to save I put the new text - as a string - into SQL. The update fails - because of all the tags and quotes,etc. that is part of the formatted string.  1. Is this the only way that permanent changes are saved in this editor? 2. If so, what sort of syntax do you use to add the HTML formatted string to a SQL statement - so it will save it properly?

    Thanks, Dave

    This is the code that I experimented with.

    public void Submit(object sender, System.EventArgs e)

    {

    string strCText, strDBConn, strSQL;

    Literal1.Visible = true;

    Editor2.Visible = false;

    btnUpdate.Visible = false;

    Literal1.Text = Editor2.Text;

    strCText = Literal1.Text;

    strDBConn = ConfigurationSettings.AppSettings["ConnectionString"];

    SqlConnection ObjConn = new SqlConnection( strDBConn );

    ObjConn.Open();

    strSQL = "UPDATE CText SET CTextContent = "+strCText+" where CTextId = 1";

    SqlCommand ObjCmd = new SqlCommand(strSQL, ObjConn);

    ObjCmd.ExecuteNonQuery();

    ObjConn.Close();

    }


     

View Complete Thread