The following is text I entered in RadEditor box:
This is a test message, but the count is not coming out quite right. What shall I do, this text is not pasted, but manually entered. Does that make a difference?
Characters: 157
but in code behind the length of text shows 163
See code below:
<
script type="text/javascript">
MyModule =
function(element)
{
MyModule.initializeBase(
this, [element]);
}
MyModule.prototype =
{
initialize :
function()
{
MyModule.callBaseMethod(
this, 'initialize');
var selfPointer = this;
this.get_editor().add_selectionChange(function (){ selfPointer.CountCharAction(); });
this.get_editor().attachEventHandler("onkeyup", function(){ selfPointer.CountCharAction(); });
this.CountCharAction();
},
//A method that does the actual work - it is usually attached to the "selection changed" editor event
CountCharAction :
function()
{
var content = this.get_editor().get_html(true);
var chars = 0;
if (content)
{
punctRegX = /[!\.?;,:&_\-\-\{\}\[\]\(\)~#
'"]/g;
content = content.replace(punctRegX,
"");
trimRegX = /(^\s+)|(\s+$)/g;
content = content.replace(trimRegX,
"");
if (content)
{
splitRegX = /\s+/;
var array = content.split(splitRegX);
chars = content.length;
}
}
var element = this.get_element();
element.innerHTML = "<span style='line-height:22px; float:left;'>" + " Characters: " + chars + " </span>"
element.style.border = "1px solid red";
element.style.backgroundColor =
"transparent";
element.style.color =
"red";
}
};
MyModule.registerClass(
'MyModule', Telerik.Web.UI.Editor.Modules.ModuleBase);
</script>
<
telerik:RadEditor ID="tbBody" runat="server" Skin="Web20" Width="500px" Height="400px"
EditModes="Design">
<Modules>
<telerik:EditorModule Name="RadEditorStatistics" Enabled="true" Visible="false" />
<telerik:EditorModule Name="MyModule" Enabled="true" Visible="true" />
</Modules>
<Tools>
<telerik:EditorToolGroup>
<telerik:EditorTool Name="Cut" />
<telerik:EditorTool Name="Copy" />
<telerik:EditorTool Name="Paste" />
<telerik:EditorSeparator />
<telerik:EditorTool Name="JustifyLeft" />
<telerik:EditorTool Name="JustifyCenter" />
<telerik:EditorTool Name="JustifyRight" />
</telerik:EditorToolGroup>
</Tools>
</telerik:RadEditor>
Code behind (shows count of 163):
string
body = tbBody.Content.Trim();
body = utils.stripHTML(body).Trim();
if
(body.Length > 1250)
{
errorMessage(
string.Format("Error: Comments can not exceed 1250 characters!"));
return;
}
| <telerik:RadGrid ID="rgQuestions" runat="server" DataSourceID="dsQuestion" AutoGenerateColumns='false' Skin="Simple" |
| AllowAutomaticUpdates='false' AllowAutomaticInserts = 'false' AllowAutomaticDeletes='false' |
| OnItemDataBound='rgQuestions_ItemDataBound' OnInsertCommand='rgQuestions_InsertCommand' OnDeleteCommand='rgQuestions_DeleteCommand' OnUpdateCommand='rgQuestions_UpdateCommand' > |
| <MasterTableView EditMode='InPlace' CommandItemDisplay="Bottom" CommandItemSettings-AddNewRecordText="New Question"> |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType='LinkButton' /> |
| <telerik:GridBoundColumn HeaderText="Question Key" DataField="QuestionKey" UniqueName="colQuestionKey" ReadOnly="True" Display="False" /> |
| <telerik:GridBoundColumn HeaderText="Inspection" DataField="InspectionKey" UniqueName="colInspectionKey" ReadOnly="True" Display='false' /> |
| <telerik:GridBoundColumn HeaderText="#" DataField="QuestionNumber" UniqueName="colQuestionNumber" /> |
| <telerik:GridBoundColumn HeaderText='Question' DataField='QuestionText' UniqueName='colQuestionText' /> |
| <telerik:GridDropDownColumn HeaderText='Asset Type' DataField='AssetTypeKey' UniqueName='colAssetTypeKey' |
| DataSourceID='dsAssetType' ListTextField='AssetType' ListValueField='AssetTypeKey' /> |
| <telerik:GridDropDownColumn HeaderText='Asset Contents' DataField='AssetContentKey' UniqueName='colContentDesc' |
| DataSourceID='dsAssetContent' ListTextField='ContentDesc' ListValueField='AssetContentKey' EnableEmptyListItem='true' /> |
| </Columns> |
| <EditFormSettings> |
| <EditColumn UniqueName="EditCommandColumn1"></EditColumn> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
| protected void rgQuestions_InsertCommand(object sender, GridCommandEventArgs e) |
| { |
| if (e.CommandName == RadGrid.PerformInsertCommandName) |
| { |
| GridDataInsertItem item = (GridDataInsertItem)e.Item; |
| Question q = new Question(); |
| q.InspectionKey = Int32.Parse(rcbInspections.SelectedValue); |
| q.AssetTypeKey = Int32.Parse((item["colAssetTypeKey"].Controls[0] as RadComboBox).SelectedValue); |
| //q.AssetContentKey = Int32.Parse((item["colContentDesc"].Controls[0] as RadComboBox).SelectedValue); |
| q.QuestionNumber = Int32.Parse((item["colQuestionNumber"].Controls[0] as TextBox).Text); |
| q.QuestionText = (item["colQuestionText"].Controls[0] as TextBox).Text; |
| q.Active = true; |
| q.Save(); |
| rgQuestions.Rebind(); |
| } |
| } |

| function OnFileSelected(sender, args) { |
| var textbox = document.getElementById("ctl00_ContentPlaceHolder1_TextBox1"); |
| var item = args.get_item(); |
| textbox.value = item.get_path(); |
| var menuEdit = document.getElementById("menuEdit"); |
| if (item.isDirectory()) { |
| menuEdit.setAttribute("class", "rmLink rmDisabled"); |
| } |
| else { |
| menuEdit.setAttribute("class", "rmLink"); |
| } |
| } |
Hi.
I am trying to combine 2 of your demo:
1) Dynamic dock
2) Custom commands
there is 2 problem:
1- after creating dynamicly a dock, the extra command button is not showed (only the 2 default one)
2 - If i fully reload the page, i can now see the custom button but the command is not trigger!
This is the code... Am i missing somethig?
if I am removing last dock.Commands.Add(d), everything works fine.
Can you help Me!
private RadDock CreateRadDockFromState(DockState state)
{
RadDock dock = new RadDock();
dock.DockMode = DockMode.Docked;
dock.ID = string.Format("RadDock{0}", state.UniqueName);
dock.ApplyState(state);
dock.Commands.Add(new DockCloseCommand());
dock.Commands.Add(new DockExpandCollapseCommand());
DockCommand d = new DockCommand();
d.AutoPostBack = true;
d.Name = "Custom Command";
dock.Commands.Add(d);
return dock;
}
protected void RadDock_Command(object sender, DockCommandEventArgs e)
{
String a = string.Concat("You clicked: ", e.Command.Name);
}
| RadGrid1.MasterTableView.FilterExpression = "(Int32?(it[""Stemaanvraagnummer""]) = " & EMO.ServiceNET.Current.Stem_ID & ")" |
| RadGrid1.MasterTableView.FilterExpression = "([Stemaanvraagnummer] = " & EMO.ServiceNET.Current.Stem_ID & ")" |
