How to set Autoconfigure property in codebehind?

Last post 04-18-2007, 7:00 PM by wrsowner. 5 replies.
Sort Posts: Previous Next
  •  04-15-2007, 4:30 AM 28397

    How to set Autoconfigure property in codebehind?

    Greetings,
     
    I am currently using the CE control in a DetailsView control for enabling users to insert/update content to their web pages.  I would like to be able to set the AutoConfigure property in the code-behind (C#) based on a user authorization setting from the database, but am having a difficult time getting it to work.  I'm aware that there are config files based on user roles, but I had built a custom login page that runs against a simple admins table before I became aware of the roles config files, and I don't have time on this project to integrate the login controls with SQL Server.
     
    Here's the general code that I've been using (note that the DetailsView control, dvContent, is in readonly="readonly" mode by default, and the CuteEditor control, Editor1, has AutoConfigure set to Full by default):
     
    ---
    if(dvContent.CurrentMode == DetailsViewMode.Edit || dvContent.CurrentMode == DetailsViewMode.Insert)
    {
       CuteEditor.
    Editor ce = (CuteEditor.Editor)dvContent.FindControl("Editor1");
       ce.AutoConfigure = CuteEditor.
    AutoConfigure.Minimal;
       Response.Write("<script>alert('" + ce.AutoConfigure.ToString() + "');</script>");
    }
    ---
     
    I have placed into the Page_Load, Page_PreRender and Page_Render events, and while the alert box above does display the new AutoConfigure setting, the editor itself never seems to make the change.
     
    I am still relatively new to ASP.NET 2.0, so I'm still feeling my way through some of this.  I was able to integrate the editor with no problem, and have been able to do most of what I need to do, but this particular setting is beating me at the moment.  So, any help with this issue would be greatly appreciated!
     
    Thanks very much in advance,
     
    -wrsowner
     
    Filed under:
  •  04-17-2007, 2:05 PM 28504 in reply to 28397

    Re: How to set Autoconfigure property in codebehind?

    So, is there just not a workaround for this?!?
  •  04-17-2007, 3:26 PM 28512 in reply to 28397

    Re: How to set Autoconfigure property in codebehind?

    wrsowner,
     
    AutoConfigure property can be set in the code and code-behind code.

    Note that this method will affect properties of the editor, so it is usually best to call it before any other property or method.

    Demo:
     
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-18-2007, 3:24 AM 28536 in reply to 28512

    Re: How to set Autoconfigure property in codebehind?

    hi Adam,
     
    Thanks for the quick response.  I am aware that this property can be set in the code-behind _if_ the editor is used in the aspx as a stand-alone control.  The issue that I'm facing currently is that the editor control is used within the Item, Insert, and Edit Templates of the DetailsView control.  When I attempt to initialize the AutoConfigure property, as described in my original post, it behaves as if I've done nothing ... I assume that may be due to the fact that I am not doing this properly, so I'm still left wondering if this is in fact possible.
     
    Thoughts?
     
    -wrsowner
     
  •  04-18-2007, 3:12 PM 28560 in reply to 28536

    Re: How to set Autoconfigure property in codebehind?

    wrsowner,
     
    I think you set this property too late. Can you explain what you are trying to achieve? I may find a work-around.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  04-18-2007, 7:00 PM 28580 in reply to 28560

    Re: How to set Autoconfigure property in codebehind?

    hi Adam,
     
    When a user logs into the admin side of this app, they either are a super admin or not.  If a SA, then I want to have the editor config'd to use the Full toolbars; if not a SA, then config'd to use the Simple toolbars.
     
    Currently, I have a couple fields and the editor set into a detailsview control, as the dv makes the data manipulation fairly easy to get done.  The editor is set as preview only in the dv for the default view of read-only; then editable when the dv is in insert or edit mode.
     
    So, from what I've been able to gather, the dv must exist prior to the editor so that dvContent.FindControl("Editor1") can be assigned to a Cutesoft.Editor variable, ce in this case.
     
    I know that the AutoConfigure property will work with no problem by removing the editor from the dv, but that basically destroys the structure of my content management section, and I will have to spend more time revamping the page (trying to avoid this path, if possible).
     
    Certainly open to ideas or possible ways to solve while maintaining the dv if you have any.
     
    Thanks again for your assistance with this!
     
    -wrsowner
View as RSS news feed in XML