web.editor not retaining text on postback

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
2/20/2013 10:18:16 AM
Gravatar
Total Posts 2

web.editor not retaining text on postback

I've created a module/feature to talk to an existing database, and it needs to store some html. I've watched the dev video @ 19 about using the mojoportal web editor, and set things up using that method.

The web editor displays html from the database fine.

However, when I go to save records, I'm always getting an empty string instead of the contents I just typed in. Does anyone have any ideas?

here is my code:

protected override void OnInit(EventArgs e)

{

base.OnInit(e);

cmdSave.Click +=

new EventHandler(cmdSave_Click);

Page.EnableViewState =

true;

if (Session["edsetup"] != "true") // did this in case the setup every time was wiping out the contents

{

SiteUtils.SetupEditor(edProdDesc);

SiteUtils.SetupEditor(edNotCovered);

Session[

"edsetup"] = "true";

}

}

 

private void PopulateControls()

{

if (!IsPostBack)

{

edNotCovered.EnableViewState =true;

edProdDesc.EnableViewState =true;

edProdDesc.WebEditor.ToolBar = mojoPortal.Web.Editor.ToolBar.AnonymousUser;

edProdDesc.WebEditor.Height =Unit.Pixel(250);

edProdDesc.WebEditor.Width =Unit.Pixel(300);

edNotCovered.WebEditor.ToolBar = mojoPortal.Web.Editor.ToolBar.AnonymousUser;

edNotCovered.WebEditor.Height =Unit.Pixel(250);

edNotCovered.WebEditor.Width =Unit.Pixel(300);

}

 

// }

}

protected void cmdSave_Click(object sender, EventArgs e)

{

string descr = edProdDesc.Text;

string notcvrd = edNotCovered.Text;

}

2/20/2013 10:27:00 AM
Gravatar
Total Posts 18439

Re: web.editor not retaining text on postback

You must setup editor in oninit every time not by session just as in existing features that use the editor.

2/20/2013 10:31:36 AM
Gravatar
Total Posts 18439

Re: web.editor not retaining text on postback

The editor configuration should also not be wrapped in a check for postback. Only thing you don't want to do on postback is initialize content in .Text property of the editor as that would lose the value entered by the user just prior to postback. Everything else about the editor must be initialized the same regardless of postback.

2/20/2013 11:10:49 AM
Gravatar
Total Posts 2

Re: web.editor not retaining text on postback

I wrapped in the check for postback, since when stepping thru, all sorts of internal mojoportal stuff seemed to be happening (including stuff that disabled viewstate).

I have removed the check for postbacks, and I'm still getting blank strings, even after typing into the html boxes.

I have incorporated your guest book, and that's working fine. So, next step is to go thru the two controls and see where the difference is, and hopefully fix it.

Thanks for the quick response!

 

You must sign in to post in the forums. This thread is closed to new posts.