Cloning Web Part

Sherry Collins asked on May 18, 2015 17:48

I have cloned a webpart and I am getting this error when I try to add it to my page. Does anyone know how to fix this. The webpart is an exact clone of the original. Nothing has been added or subtracted.

[Error loading the WebPart 'RaceTracPoll' of type 'RaceTracPoll']

Correct Answer

Charles Matvchuk answered on May 18, 2015 21:30

There was a syntax error in my code above, please see below, it wouldn't let me change it. I was missing a double quote.

const string SQL = "Insert into form_IntranetPortal_CommentForm (CommentBox) Values(@CommentBox)";

0 votesVote for this answer Unmark Correct answer

Recent Answers

Petar Kozjak answered on May 18, 2015 19:35 (last edited on May 18, 2015 19:35)


can you share more info like what version and is it cloning on same page or was it copied to another page?

Usually when something like this happens we remove and copy it again.

0 votesVote for this answer Mark as a Correct answer

Sherry Collins answered on May 18, 2015 20:16

I am using version 8.2. What I am trying to do is clone the poll web part and add a comment box on it. When the poll closes, then they want the poll to disappear and the comment box to appear.

I am sorry to be such a bother, but I have just been thrown into Kentico with little or no help. They told me everything would be out of the box and it turns out that everything is a customization.

I am having trouble with the cloning, but more importantly, I am having trouble making a database call to save the comments. I am from and normally I would use to save the data back to the database.

Is that appropriate in Kentico. I am not knowledgeable about the various classes.

This is my code for the click event on the new button

SqlConnection conn = new SqlConnection(); conn.ConnectionString = "Server=(localdb)\v11.0;Integrated Security=true";

    SqlCommand cmd = new SqlCommand();
    cmd.CommandText = "Insert into dbo.form_IntranetPortal_CommentForm(CommentBox) Values(" + pollcommentbox.Text + ")";

    cmd.Connection = conn;
    pollcommentbox.Text = "Thank You For Your Comment";

This is the markup for the new comment box

Please Leave A Comment

After entering data into the comment box then when I look back into the database there is nothing in the table. I am doing this from my local where I am not getting any errors when I pull the clone on. The cloning errors are occurring on another box.

Any help you could provide would be appreciated.

0 votesVote for this answer Mark as a Correct answer

Charles Matvchuk answered on May 18, 2015 21:11 (last edited on May 18, 2015 21:26)

Sherry, the code above for is not good, it allows for SQL Injection Attacks, you should always use parameters and AddWithValue. Additionally, you should always conn.Dispose(), close is not enough. Or wrap it in a using statement. Also your conn may not be working.

using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CMSConnectionString".ConnectionString))
const string SQL = "Insert into form_IntranetPortal_CommentForm (CommentBox) Values(@CommentBox);
SqlComand cmd = new SqlCommand(SQL, conn);
cmd.Parameters.AddWithValue("CommentBox", pollcommentbox.Text ?? "");



0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.