RADEditor's elements' CSS properties not getting overridden - c#

I added this in the head section of my page as told in the article..added the following two additional lines to get rid of the background image(RADEditor on my page is inheriting master page's bg image)
.reContentCell
{
background-image:none;
background-color:White;
}
.reDropDown{color:Aqua;}
Why are the changes not taking place?
[EDIT]
added !important to both the properties above...still can't see no change
[EDIT]
I am using RADEditor in like MANY pages soo was wondering if I can do some coding in the Master Pages ..like in Master Page I can detect if there's some radEditor in any of the ContentPlaceholders..then I can add the CSS file to be used for that Editor so it doesn't inherit master page's CSS properties...so how do i go about it ?? How do I search for radEditor in Content pages and then add CSS to it ???
[EDIT]
I have already tried the following :-
ie adding CustomSkin's CSS classes to Editor
<telerik:RadEditor ID="Editor1" EnableEmbeddedBaseStylesheet="true" runat="server">
<CssFiles>
<telerik:EditorCssFile value="Skins/CustomSkin/Editor.CustomSkin.css"/>
<telerik:EditorCssFile value="Skins/CustomSkin/Editor.CustomSkin.css"/>
<telerik:EditorCssFile value="Skins/CustomSkin/Editor.CustomSkin.css"/>
</CssFiles>
</telerik:RadEditor>
In the page's head section :-
I gave reference of CSS files...now its working fine..Editor is not getting screwed up or anything coz of Master page's CSS ...BUT what I want is some way to do this in the master page's code itself like I said above..plz help..thnx
[EDIT]
Master page's code behind :-
if(ContentPlaceHolders.Contains("what to type here??")){}
Intellisense is not showing Telerik RadEditor option in the drop down list
Is there some other way to add Editor's CSS files programmaticaly in master page's code behind??

use
.reContentCell, .reContentCell iframe
{
background-color:#FFFFFF !important;
}
because the original css file is adding a background colour to both the cell and the iframe.

Related

Override in child page content and style of nav from master

Do you know a method that completely wipes out a <nav class="navClass"> from a master page, or replaces it by <nav> (no content, no styling in between) </nav>?
I tried
<style>
.navClass { width: 0px !important; }
</style>
This takes effect on styling only, but if I have text in between, it will not be removed.
I have solved this in c# by putting a condition on the masterpage.
<% if ( // condition to not apply for child of certain type { %>
//here, original definition with content and style
<% } %>
But I want to know if there is something more effective that can be used on the child directly to remove the nav, in either c# or css, avoiding javascript.
Maybe I can assign it with ID in master and use it to override it in the child?
Thanks!
I came across this link for finding a solution. Check if it is useful Access an HTML control on ASP Master Page from the code behind of a Content Page
One way you could do is to remove the classes for the nav element via jQuery.
Code below will remove all associated classes for nav.
$(document).ready(function(){
$('nav').removeClass();
});

Update ContentPlaceHolder with Ajax?

Say i have a MasterPage and two subpages, that are included through the ContentPlaceHolder.
Would it possible in AJAX to update the ContentPlaceHolder to change from 1 subpage to another?
And if so, are there any problems that i may encounter by using this type of interface?
You can't use ContentPlaceHolder control, since it will not be rendered in your page.
Please use div runat="server" and use div id to load the ajax content
All the scripts in the page will work fine loaded via ajax. There are few scenarios it will break/conflict with the parent page script. In that case, you can use iframe and set a src attribute

Loading a ASPX CSS file into a telerik StyleSheetManager declared inside a master page

How do you load a ASPX CSS file into a telerik StyleSheetManager declared inside a master page?
Is there something like a scriptManagerProxy equivalent for CSS and Telerik's style sheet manager?
You can get the reference to the stylesheet manager using a static method:
RadStyleSheetManager.GetCurrent(this.Page).StyleSheets.Add(..);
Similar to the ScriptManager.GetCurrent(this.Page) method.

Creating web controls inside a content placeholder programmatically

I've got a master page and a content page. How can I add controls to the master page's content placeholders programmatically?
Try something like following:
this.Master.Controls.FindControl("ContentPlaceHolderID").Controls.Add(yourControl);
this.Page.Master.FindControl
As said above would work fine.
Alternatively, make whatever placeholder in your master page a ContentPlaceHolder, and then your child pages can put stuff there directly without having to go up through the Master page.

Element-Enhancing Javascript in ASP.NET Master Pages

I have run in to a bit of a problem and I have done a bit of digging, but struggling to come up with a conclusive answer/fix.
Basically, I have some javascript (created by a 3rd party) that does some whizzbang stuff to page elements to make them look pretty. The code works great on single pages (i.e. no master), however, when I try and apply the effects to a content page within a master, it does not work.
In short I have a master page which contains the main script reference. All pages will use the script, but the parameters passed to it will differ for the content pages.
Master Page Script Reference
<script src="scripts.js" language="javascript" type="text/javascript" />
Single Page
<script>
MakePretty("elementID");
</script>
As you can see, I need the reference in each page (hence it being in the master) but the actual elements I want to "MakePretty" will change dependant on content.
Content Pages
Now, due to the content page not having a <head> element, I have been using the following code to add it to the master pages <head> element:
HtmlGenericControl ctl = new HtmlGenericControl("script");
ctl.Attributes.Add("language", "javascript");
ctl.InnerHtml = #"MakePretty(""elementID"")";
Master.Page.Header.Controls.Add(ctl);
Now, this fails to work. However, if I replace with something simple like alert("HI!"), all works fine. So the code is being added OK, it just doesn't seem to always execute depending on what it is doing..
Now, having done some digging, I have learned that th content page's Load event is raised before the master pages, which may be having an effect, however, I thought the javascript on the page was all loaded/run at once?
Forgive me if this is a stupid question, but I am still relatively new to using javascript, especially in the master pages scenario.
How can I get content pages to call javascript code which is referenced in the Master page?
Thanks for any/all help on this guys, you will really be helping me out with this work problem.
NOTES:
RegisterStartupScript and the like does not seem to work at any level..
The control ID's are being set fine, even in the MasterPage environment and are rendering as expected.
Apologies if any of this is unclear, I am real tired so if need be please comment if a re-word/clarification is required.
Put a ContentPlaceHolder in the head section of the master page, then add a asp:Content control on the content page referring to the placeholder and put your script in that control. You can customize it for each page this way.
Also, the reference by ID may not be working because when you use Master Pages, the control IDs on the page are automatically created based on the container structure. So instead of "elementID" as expected, it may be outputting "ctl00_MainContentPlaceHolder_elementID" View your source or use firebug to inspect your form elements to see what the IDs outputted are.
Isn't it possible to do with clean javascript ?-)
-- just add something similar to this inside the body-tag:
<script type="text/javascript">
window.onload = function(){
MakePretty("elementID");
}
</script>
By the way the script-tag has to have an end-tag:
<script type="text/javascript" src="myScript.js"></script>
Why not use jQuery to find all the controls? Something like this:
$(document).ready(function(){
$("input[type='text'], input[type='radio'], input[type='checkbox'], select, textarea").each(function(){
MakePretty(this);
});
});
This way you'll get all elements on the page, you can wait until the page is ready (so you don't modify the DOM illigally). The jQuery selector can get the elements in a bit more of a specific format if you need (ie, add a root element, like the ID of the body div).
It'd also be best to modify the MakePretty method so it takes the element not the ID as the parameter to reduce processing overhead.
Once you use Master Pages, the ids of controls on the client side aren't what you think they are. You should use Control.ClientID when you generate the script.
When using master pages, you need to be careful with the html attribute ID, since .NET will modify this value as it needs to keep ids unique.
I would assume your javascript is applying css styles via ID, and when you are using master pages the ID is different than what is in your aspx. If you verify your javascript is always being added, your answer needs to take into account the following:
ALWAYS set your master page id in page load (this.ID = "myPrefix";)
Any HTML element in your master page will be prefixed by the master page id (i.e.: on the rendered page will be "myPrefix_myDiv")
Any HTML element in your content place holder id will be prefixed with an additional prefix (i.e. myPrefix_ContentPlaceHolderId1_myDiv)
Please let me know if I can clarify anything. Hope this helps!

Categories