trying to disable the telerik editor control in asp - asp.net

I was thinking to do this server side, but what i was wanting to do was disable the telerik control called the "Editor." Located at the site: telerick editor control.
My reasoning behind this was that I wanted to give a user the exact look and feel of the object while having everything disabled. I didnt want to use an image at all because it would be stretched, shrank, clicked, etc and wanted to maintain how the editor would look. I had an alternate option i COULD do but not only it would be ineffecient, but have holes to open up for injection.
Looking through the API for that i didnt see which way to accomplish that.
I was thinking to do jquery maybe on the client side to disable, but why do that when you can set the item itself be flagged as disabled and never be entirely sent to the client.
Thoughts? Ideas? How would you go about it? I didnt see methods or attributes that really led to what i was doing.

You can just set enabled="false" on the radEditor declaration in your aspx page:
http://www.telerik.com/help/aspnet-ajax/editor-disabling-radeditor.html
<telerik:RadEditor runat="server" ID="RadEditor1" Enabled="false">
<Content>
<strong>sample content</strong>
</Content>
</telerik:RadEditor>
On the Server Side you can do
RadEditor1.Enabled = false;

In jquery,
try
$("#RadEditor1").prop('disabled', true);

Related

Modern HTML WYSWYG Editor for ASP.Net Web Forms application

I'm looking for some kind of HTML WYSWYG editor solution for an ASP.Net Webforms application. We currently use AjaxToolkit, but it doesn't support pasting images, is not really accessible, etc. I came accross FreeTextBox, but it seems to not support image pasting either, and it's been a big headache to configure properly given that the documentation is not all that descriptive. I've gotten the image gallery to work finally, but it looks pretty terrible, and I'm not sure the images will actually show up in the email (they were broken in my testing environment using the Papercut SMTP emulator). Just wondering if there are any other options I have with a Web Forms app, or am I limited to solutions that are as old as Web Forms?
you can try CKEditor(it have editable tool panel and spell checker)
https://ckeditor.com/cke4/builder
this free js library, easy integrate and if you want send result to .aspx.cs side should use call back by DevExpress control
I still use the ajaxtoolkit HTML editor. It is a bit dated, but I do find without any special settings, that I can paste in in images.
So, say I drop in a text box, use extender, and add HTML editor.
So, say this:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server" Width="1309px"
TextMode="MultiLine" Rows="40" ></asp:TextBox>
<ajaxToolkit:HtmlEditorExtender ID="TextBox1_HtmlEditorExtender" runat="server"
BehaviorID="TextBox1_HtmlEditorExtender"
EnableSanitization="False"
TargetControlID="TextBox1">
</ajaxToolkit:HtmlEditorExtender>
I am able to put a picture in my paste buffer, and a simple ctrl-v does paste the picture:
eg this:
As noted, I think the tool bar etc. does look quite outdated, but my experiance with the toolkit is that ctrl-v to paste in a picture does work.
As suggested, the other possible is ckedit, and it should work with asp.net web pages.
Its not clear why using the ajaxtoolkit editor does not allow cut + paste of images - my experience does seem to work. Perhaps you need sanitation=false?
As noted, the other suggestion here was CKEditor, and that seems like a good choice also.

Can't reference controls in code behind. Visual Studio 2012

There are quite a few questions out there regarding this (for me, recurring) issue, but none of them have solved my problem.
Problem:
Whatever control I add in my aspx page, it is not recognised in the codebehind. Compiling doesn't work, because the ID is not recognised.
None of the following worked:
Clean and rebuild solution.
Close and open VS
Delete asp.net temp files
Check project's target framework.
Check assemblies are all there.
Check designer viewn to see if the control is actually there (it is)
Get control's ID with JS function to check it is the intended one (it is)
The problem has started only recently. In fact, I can reference the older controls fine.
The problem is observed both with standard ASP controls and Telerik ones.
Does anyone know of something else I should try? Please help me, I'm in the middle of a project and this is causing unnecessary delays, ta.
Make sure all of your asp.net controls (in the .aspx file) have the:
runat='server'
tag... Without this, you will not be able to reference the controls.
e.g.
<asp:Label runat='server' Text='Test Label' ID='TestLabel' />
Hope this helped...
Rodit
This is how I solved my issue. For a full account of it, please refer to the comments above.
I've noticed that although my project was already of web application type, designer files weren't showing.
I've forced the designer files to be recompiled by clicking on the ''convert to web application' option
I was then able to reference the control ID.
Thanks to the commentators anyway.
I was having a similar issue, due to the fact that I was using the pre-generated Login page. My solution was to change this section from this:
<asp:Login runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
To this:
<asp:Login ID="asplogin" runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
basically, I just added an ID to the asp:Login which allowed me to access the objects in the code from behind by prefixing the control name with asplogin
asplogin.youControlNameHere

Calendarextender is not displayed with masterpages

I'm working with masterpages and after reading a lot of answers I can't find why my calendarextender doesn't appear
Here is my code
http://pastebin.com/m789f935e
did you check the setting in the webconfig file . do you have all the required settings for ajax . ?
Have you tried changing the TagPrefix in the
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
directive to something other than asp? Not sure how well referencing more than one assembly for a single TagPrefix is supported.
The info here and here sort of backs me up...sort of. Give it a shot and let us know how it goes.
I see you have more than one ScriptManager tag... one in the Master page and one in your VerFavoritos.aspx page. I suggest you add one ScriptManager in the Master, place it right after the tag and before anything else in the Master page. Remove any ScriptManager tags from the VerFavoritos.aspx page.
Hope this helps.
Do you have the AJAX Control Toolkit .dll in your References?
The entry in the web.config you are looking for is something along this line:
<add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="AjaxControlToolkit"/>
When this happens you can use the calendar extender with syntax like:
<AjaxControlToolkit:CalendarExtender ... />
Rebor.
My application have a page that displays a ModalPopUp (the modal pop up pf ajax toolkit).
Inside the PopUp i put a calendarExtender, but the calendar appears behind the PopUp, so, to solve it i need to associate my Calendar to a CSS, like this:
<cc1:CalendarExtender ID="txtProximoContato_CalendarExtender" runat="server" PopupButtonID="imgCalendarProxContato"
Enabled="True" CssClass="CalendarPopup" TargetControlID="txtProximoContato">
</cc1:CalendarExtender>
and the CSS class
.CalendarPopup
{
z-index: 10500 !important;
}
I dont know if it is your problem, but i hope this help you
To be honest the Ajax Control Toolkit has been superceded by things like jQuery. Seriously consider using jQuery UI or extjs instead - I've always found this library to buggy and badly supported.
I copied/pasted your code almost exactly as it was and the calendar extender appeared.
Follow these steps exactly and it should work for you
Uninstall and reinstall AJAX 1.0.
From within VS 2005, create an "AJAX Enabled Website" instead of a regular website (VS 2008 automatically creates this type of website).
Add a reference to AjaxControlToolkit and it should work.
If you are still having trouble
Send me your solution. I'll correct it and send it back to you.

Validator in <noscript> causes JavaScript error

The following .NET 3.5 code, placed in an aspx file, will trigger a JavaScript error when the page is loaded (for users who have JavaScript enabled):
<noscript>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="txt_RequiredFieldValidator" runat="server"
ControlToValidate="txt"></asp:RequiredFieldValidator>
<asp:Button ID="btn" runat="server" Text="Button" />
</noscript>
The error happens because the JavaScript generated by the ASP.NET validator control does not contain a null check on before the second code line below:
var ctl00_body_txt_RequiredFieldValidator =
document.all ?
document.all["ctl00_body_txt_RequiredFieldValidator"] :
document.getElementById("ctl00_body_txt_RequiredFieldValidator");
ctl00_body_txt_RequiredFieldValidator.controltovalidate = "ctl00_body_txt";
Can anyone suggest a workaround to this?
Footnote: Why am I doing this? For my non-JavaScript users I am replacing some AJAX functionality with some different UI components, which need validation.
You should add the following to the RequiredFieldValidator:
enableclientscript="false"
Seeing as you are using these in <noscript> tags, there is no point in supplying client side vaildation of the controls - they are only going to display if JS is turned off.
This will force the validation to happen (automatically) on the server side for you.
Just make sure you call "Page.IsValid" before you process the response.
See BaseValidator.EnableClientScript for more details.
The javascript is looking for an element contained in the noscript? AFAIK there's no clean way to detect script support from the server side.
I think you'll need to build in a redirect (I've seen this done with a meta-refresh in a header noscript if you don't mind a validation failure) to push noscript users to a "please turnscript on page" or do some surgery to loosen up the validation/control binding which may take some amount of wheel reinventing. This is one of those areas where asp.net's tight coupling between controller and view really punishes.

When to use HtmlControls vs WebControls

I like HtmlControls because there is no HTML magic going on... the asp source looks similar to what the client sees.
I can't argue with the utility of GridView, Repeater, CheckBoxLists, etc, so I use them when I need that functionality.
Also, it looks weird to have code that mixes and matches:
<asp:Button id='btnOK' runat='server' Text='OK' />
<input id='btnCancel' runat='server' type='button' value='Cancel' />
(The above case in the event you wanted to bind a server-side event listener to OK but Cancel just runs a javascript that hides the current div)
Is there some definitive style guide out there? Should HtmlControls just be avoided?
It might be useful to think of HTML controls as an option when you want more control over the mark up that ends up getting emitted by your page. More control in the sense that you want EVERY browser to see exactly the same markup.
If you create System.Web.UI.HtmlControls like:
<input id='btnCancel' runat='server' type='button' value='Cancel' />
Then you know what kind of code is going to be emitted. Even though most of the time:
<asp:Button id='btnCancel' runat='server' Text='Cancel' />
will end up being the same markup. The same markup is not always emitted for all WebControls. Many WebControls have built in adaptive rendering that will render different HTML based on the browser user agent. As an example a DataGrid will look quite different in a mobile browser than it will in a desktop browser.
Using WebControls as opposed to HtmlControls also lets you take advantage of ASP.NET v2.0 ControlAdapters which I believe only works with WebControls, this will allow you programatic config driven control over the markup that gets emitted.
This might seem more valuable when you consider that certain mobile browsers or WebTVs are going to want WML or completely different sets of markups.
In my experience, there's very little difference. As Darren said, if you don't need server-side functionality, HTML controls are probably lower-impact.
And don't forget, you can bolt server-side functionality onto almost any HTML control just by adding a runat="server" directive and an ID to it.
well... i wouldn't use an html control if you don't need to do anything on it on the server. i would do
<input id='btnCancel' type='button' value='Cancel' />
fin.
By adding runat="server" you can get access to any HTML controls in server side..
and I believe HTML controls are less weight compared to ASP.NET server controls..

Resources