Customize Images, Links, Code Snippet Dropdowns

Last post 02-09-2004, 8:46 PM by Adam. 8 replies.
Sort Posts: Previous Next
  •  02-09-2004, 7:26 AM 332

    Customize Images, Links, Code Snippet Dropdowns

    I have not seen anything in the documentation or support about customizing these 3 dropdowns.  Am I missing the documentation on this?

     

  •  02-09-2004, 12:26 PM 341 in reply to 332

    Re: Customize Images, Links, Code Snippet Dropdowns

    I found code in the samples that shows how to add items to these drop downs:


    Public Sub Page_Load(sender As object, e As System.EventArgs)

     

     Dim contactstring As String    
     contactstring = "Contact us"  
      
     Editor1.StyleDropDown.Items.Add(new ListItem("Style 1","Heading"))
     Editor1.StyleDropDown.Items.Add(new ListItem("Style 2","Head"))
     Editor1.StyleDropDown.Items.Add(new ListItem("Style 3","Subhead"))
     Editor1.StyleDropDown.Items.Add(new ListItem("Style 4","NormalRed"))
     Editor1.StyleDropDown.Items.Add(new ListItem("Style 5","Comment"))

     
    End Sub


    I am using the editor in a datagrid in the edit template and the footer(new item).  I have the editor functioning correctly, but the population of these dropdowns, using the above code causes the following error:


    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       sailfish.Manage_News.Page_Load(Object sender, EventArgs e) +52
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +731
    


    Any ideas why this is happening?

  •  02-09-2004, 1:11 PM 342 in reply to 341

    Re: Customize Images, Links, Code Snippet Dropdowns

    The "Object reference not set to an instance of an object. " error occurs when you try to access something that isn't there (null or
    Nothing).

     

    What's your editor control ID?


    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

  •  02-09-2004, 1:19 PM 344 in reply to 342

    Re: Customize Images, Links, Code Snippet Dropdowns

    Protected WithEvents Editor1 As CuteEditor.Editor

  •  02-09-2004, 1:28 PM 345 in reply to 344

    Re: Customize Images, Links, Code Snippet Dropdowns

    Does it have to do with the fact that it is in a Datagrid and the controls are named by the page?  Is there a way to do this before the control is renamed?
  •  02-09-2004, 7:47 PM 350 in reply to 345

    Re: Customize Images, Links, Code Snippet Dropdowns

    Yes, we need to do this in the DataGrid item's ItemDataBound event. I just got this working. Please check the following link:

     

    http://cutesoft.net/Example/DataGrid_vb.aspx

     

     

    I will write a note show how to use CuteEditor in the template control of a datagrid.

     


    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

  •  02-09-2004, 8:09 PM 352 in reply to 350

    Re: Customize Images, Links, Code Snippet Dropdowns

    Thanks for the help.  I will implement it that way and post the results
  •  02-09-2004, 8:12 PM 353 in reply to 352

    Re: Customize Images, Links, Code Snippet Dropdowns

    If you could post the code snippet you used, that would help to start.
  •  02-09-2004, 8:46 PM 355 in reply to 353

    Re: Customize Images, Links, Code Snippet Dropdowns

    OK.

     

    You need to use the itemdatabound method for the datagrid. The ItemDataBound of the DataGrid occurs when data is bound to a item in a DataGrid control. This note explains how to use CuteEditor for .NET in the template control of a datagrid.

     

     

     

    <asp:Datagrid runat="server"

          Id="MyDataGrid"

          AutogenerateColumns="False"

          OnItemDataBound="onDataBound"           //

          OnEditcommand="MyDataGrid_EditCommand"

          OnCancelcommand="MyDataGrid_Cancel"

          OnUpdateCommand="MyDataGrid_UpdateCommand">

         <Columns>

                <asp:EditCommandColumn

                      ButtonType="LinkButton"

                      UpdateText= "Update"

                      CancelText="Cancel"

                      EditText="Edit"

                      ItemStyle-HorizontalAlign="Center"

                      HeaderText="Edit">

                </asp:EditCommandColumn>

                 <asp:BoundColumn

                      DataField="EmployeeID"

                      HeaderText="EmployeeID"

                      ReadOnly="True">

                </asp:BoundColumn>

                <asp:TemplateColumn HeaderText = "Title">

                       <ItemTemplate>

                          <%# DataBinder.Eval(Container.DataItem, "FirstName") %>

                       </ItemTemplate>

                       <EditItemTemplate>

                             <CE:Editor id = "FirstName_box"
                                     AutoConfigure="EnableAll" 

                                     DisableItemList="save"

                                     Text = '<%#DataBinder.Eval(Container.DataItem, "FirstName") %>'

                                     runat = "Server" >

                             </CE:Editor>

                      </EditItemTemplate>

                </asp:TemplateColumn>

           </Columns>

    </asp:DataGrid>

     

     

    Specify an event handler for the DataGrid's ItemDataBound.This event handler should be mapped to the OnItemDataBound property of the DataGrid control

     

     <script language="VB" runat="server">

            Sub onDataBound(sender as Object, e as DataGridItemEventArgs)

                  If e.Item.ItemType = ListItemType.EditItem Then

                        Dim txtFirstName As CuteEditor.Editor

                        txtFirstName = CType(e.Item.FindControl("FirstName_Box"), CuteEditor.Editor)

                        txtFirstName.StyleDropDown.Items.Add(new ListItem("Style 1","Heading"))

                        txtFirstName.StyleDropDown.Items.Add(new ListItem("Style 2","Head"))

                        txtFirstName.StyleDropDown.Items.Add(new ListItem("Style 3","Subhead"))

                        txtFirstName.StyleDropDown.Items.Add(new ListItem("Style 4","NormalRed"))

                        txtFirstName.StyleDropDown.Items.Add(new ListItem("Style 5","Comment"))

                  End If

             End Sub

    </script>

     

    If you have any further question, please let me know.

     

     


    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

View as RSS news feed in XML