Hello Daniweb!
I'm an amateur programmer who's learned quite a bit from online references, and usually searching eventually reveals the problem but I'm stuck!
I've overcome many obstacles when creating a custom button on the Ajax Editor control, namespace issues, registring the controls properly etc. I resist the temptation to ask for help because the errors should lead me in the right direction. Now I get no errors, but the control isn't visible! The tag is in the .ASP page and I even set the width, height and visible tags in case it's being hidden but nothing shows up.
This is my MaintainKB.aspx
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
CodeBehind="MaintainKB.aspx.vb" ValidateRequest="false" Inherits="Quartet_KB.WebForm6" %>
<%@ Register TagPrefix="cus" TagName="KBCustomHtmlEditor" Src="~/KBCustomHtmlEditor.ascx" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:PlaceHolder id="MessagePlaceHolder" runat="server"></asp:PlaceHolder>
<asp:ToolkitScriptManager ID="ToolkitScriptManager" runat="server">
</asp:ToolkitScriptManager>
<table class="pageheadertable">
<tr>
<td width="50%" class="pageheadertable">
Maintain KB article:
<asp:Label ID="lKbNumber" runat="server"></asp:Label>
</td>
</tr>
</table>
<br />
<table class="subpageheadertable">
<tr>
<td>
<asp:Label ID="lSubject" runat="server" Text="Subject"></asp:Label>
</td>
<td>
<asp:TextBox ID="tSubject" runat="server" Width="400px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lKeywords" runat="server" Text="Keywords"></asp:Label>
</td>
<td>
<asp:TextBox ID="tKeywords" runat="server" Width="400px"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="bSave" runat="server" Text="Save" />
<asp:Button ID="bCancel" runat="server" Text="Cancel" />
</td>
</tr>
</table>
<br />
<cus:KBCustomHtmlEditor ID="textHTML" width="100%" height="200px" Visible="true" runat="server" />
<script language="javascript" type="text/javascript">
function show() {
document.getElementById("<%=dv.ClientID%>").style.display = '';
document.getElementById("<%=FileUploadControl.ClientID%>").style.display = '';
document.getElementById("<%=btnUpload.ClientID%>").style.display = '';
document.getElementById("<%=btnCancel.ClientID%>").style.display = '';
showFloatDiv();
}
function hide() {
document.getElementById("<%=dv.ClientID%>").style.display = "none";
document.getElementById("<%=FileUploadControl.ClientID%>").style.display = "none";
document.getElementById("<%=btnUpload.ClientID%>").style.display = "none";
document.getElementById("<%=btnCancel.ClientID%>").style.display = "none";
}
function showFloatDiv() {
if (!e) {
var e = window.event || arguments.callee.caller.arguments[0];
}
var scrolledV = scrollV();
var scrolledH = (navigator.appName == 'Netscape') ? document.body.scrollLeft : document.body.scrollLeft;
tempX = (navigator.appName == 'Netscape') ? e.clientX : event.clientX;
tempY = (navigator.appName == 'Netscape') ? e.clientY : event.clientY;
document.getElementById("<%=dv.ClientID%>").style.left = (tempX + scrolledH) + 'px';
document.getElementById("<%=dv.ClientID%>").style.top = (tempY + scrolledV) + 'px';
document.getElementById("<%=dv.ClientID%>").style.display = "";
}
function scrollV() {
var scrolledV;
if (window.pageYOffset) {
scrolledV = window.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop) {
scrolledV = document.documentElement.scrollTop;
}
else if (document.body) {
scrolledV = document.body.scrollTop;
}
return scrolledV;
}
</script>
</asp:Content>
And here is the KBCustomHtmlEditor.vb file where I modify my control.
Imports AjaxControlToolkit.HTMLEditor
Namespace MyControls
Public Class KbCustomHtmlEditor
Inherits Editor
Private Shared _editorBlogID As Integer = -1
Public Shared Property EditorBlogID() As Integer
Get
Return _editorBlogID
End Get
Set(value As Integer)
_editorBlogID = value
End Set
End Property
Protected Overrides Sub FillTopToolbar()
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold())
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic())
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy())
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut())
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Paste())
TopToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.Redo())
Dim btn As New AjaxControlToolkit.HTMLEditor.ToolbarButton.MethodButton()
btn.NormalSrc = "images/upload.png"
btn.ID = "btnUplaodImg"
btn.Attributes.Add("onclick", "show();")
'this method show() is calling from user control where we add the reference
TopToolbar.Buttons.Add(btn)
End Sub
Protected Overrides Sub FillBottomToolbar()
BottomToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.DesignMode())
BottomToolbar.Buttons.Add(New AjaxControlToolkit.HTMLEditor.ToolbarButton.PreviewMode())
End Sub
End Class
End Namespace
Anyway, if anyone can point out my blunder I'd be very grateful!