How to change Asp.net Theme via Web.Config on the fly - c#

Summary
I have a web-application with more than 5 themes. Each themes covers a completely different style for different customers. whenever we publish a new version of our application we send it for all of customers.
The problem.
We specify theme in web.config file in <Page> tag. like
<page theme="Theme1" /> // or Theme2 for second customer.
with this approach we easily change the style of application from each other without writing codes which needs a new publish for each one.
With changing the theme="Theme1". nothing change and we didn't write a code in application , so why changing theme don't change the theme and we need a new publish?
we want to change it in web.config or somewhere else and with changing it the theme change without needing a new publish for each one.
Update :
I Publish Once and then copy the published version for each customer (5 times) then in each web.config file I change the theme="CustomerTheme". but only the theme which was active in publish process is usable in all of 5 versions and other 4 themes are un-usable
--
Actually the main question is that why changes in Web.Config need a different publish while it is XML and do not need a complie. I should Add this note that, App_Theme include all of 5 themes so that all of them Compiles and are ready to use
--
This is the way I publish the application
Photo Link
Update 2
here IFound the exact problem reported by someone else. he resolve the problem but I can't underestand how he resolved this Issue. can anybody tell me how he resolved the issue?
he used aspnet_compiler command and told that automatically ADDS the 'theme' on the Page directive
(first post is the question and the last post is the answer)
http://bytes.com/topic/asp-net/answers/495850-themes-web-config

If I understood you correctly, you have one theme for each customer and that will not change?
Still, I do not understand your publishing scenario? Why do you want to change the Theme if each customer has its own web application?
Nevertheless, how about you check the request url in the codebehind and set the Theme Name programatically?
Pseudo-code: (you need to have this piece of code executed on every request. You could write an HTTPHandler for this, or use the BeginRequest Event in the global.asax. You also need to find which property provides the necessary URL information)
switch(Request.URL)
{
case "www.customer1.com":
Theme = "Customer1";
break;
case "www.customer2.com":
Theme = "Customer2":
break;
}

Did you publish the app as precompiled? If so this could be the cause.
Why not store the theme to use in a database table and access it there rather than the web.config? This should then be truly 'on the fly'.

Even though this is a really old post, I don't think the accepted answer is the best one. On this link, https://bytes.com/topic/asp-net/answers/495850-themes-web-config is a correct answer, but not as clear as it should.
He mentioned that the compiler is adding the theme to every page, so then it can't be changed by web.config file on the server. But he didn't say what to do to avoid this and it is pretty simple. You just have to remove the theme='Theme1' from web.config before compiling the web site. If it is not there, then the compiler would not set the theme to every page and you can change the theme just by web.config on every server you like with the same exact code.

Related

How to create ContentPart in orchard cms theme?

I am trying to design an orchard theme in which i need to attach some Content Part to MenuItem to add some extra info for that.I did the process of adding part as i do inside module ,but strangely enough my view didn't get displayed.after hour's of debugging i figured out that my part's editor shape (eg:Parts_MenuItemMetaPart_Edit) is added to ShapeTable of my frontend theme rather than admin theme(TheAdmin) and thus my attached part editor not displayed.so is there any possibility to create a content part from within theme?if yes, how ?
Just found this link : https://github.com/OrchardCMS/OrchardDoc/blob/master/Documentation/Add-Custom-Settings-to-your-Theme.markdown
from the link above :
... You may be wondering why we don’t just use a driver like we usually do for a parts editor template. This is due to the fact that to call the Editor method of your Driver and return a shape, you need to have specified in the Placement.info that you want to do that. Since this theme is not active in the admin section of Orchard, our themes Placement.info file is never run hence a Driver would never display anything...
So the solution is to add ActivatingFilter in ContentPartHandler like this :
Filters.Add(new ActivatingFilter<MyPart>("Site"));
for more info follow the link provided.

Publish deleted items

I'm facing some problems, somehow to provide to content authors solution/advice to delete huge sections of website translated (having language versions) and with references set on presentation or data items inside content tree.
Removing all items plus references raise another problem how to make the changes visible on web database. Publish cannot be used, even workflow is present changes are made on presentation (master instance is mapped to a preview site for client) on pages (by different agencies) and cannot reach live, only when they decide to. Used as well number of versions per language (limited to 6, rest removed) if all 6 variants are trapped in workflow publish will publish item with all fields empty, we don't want to have a blank page.
And there are other concerns regards incorrect work, sometimes agencies publish/submit incorrect/unproved content and they blame each other case someone publish accidental pages (presentation settings/datasource) so i want to pick the best strategy here not to give room for content authoring agency's to blame their incorrect work other then them.
I have few approaches to do it right but..
do same deletion of items on web database via CMS in theory works (tested on locally in sitecore 7.2 - works) on Production CMS (Sitecore 7.0 - admin rights, no access to server files for me) fails as in next image:
write a module (Sitecore command to remove all references and removing/recycling web database item cannot be performed via code because it will trow same error as above)
Question 1. Why this error occurs at CMS item deletion if web database is selected (Sitecore 7.0)
Found in this deprecated post something what seems to be the solution: Add publishing commands to the recycle bin. Well here I get a bit blocked, adding the publish command on Recycle Bin ribbons, don't know if it's possible to do this (what I'm publishing I do not understand). I created something but it's not working:
This is the result :(
Question 2. Is publishing commands to the recycle bin possible? If yes please help me with a documentation to implement it and understated what/how is published.
If you have other suggestions (beside publish item + sub items or publish website) please help me out.
Thank You.

C# asp.net application, changes to Site.css do not seem to affect Site.Master

I just started an asp.net c# project and I was trying to change the text-align of the .title and background color of the .header. I add the required code to the style sheet, but nothing changes in the header of the form. I'm probably missing something simple here, can someone point me in the right direction?
Stylesheets are usually cached by the browser to speed up browsing.
You can either force-refresh (SHIFT+F5) or append a value to the stylesheet path to cache-bust it.
style.css?v1
By changing v1 whenever you want a change to be forced out to all browsers, it will replace the cached version as resources are cached per URI.
Just try stopping your Local development server and do clean and build solution before running the application.
Even clear your temporary internet folder which may contain stale copy of your css file.
Right clicking in the markup view , you should see an options that says view in browser. This should reload anything cached.

ASP.NET : Globalization error

I've a problem with serialization both in silverlight and asp.net.
I've added this line to my web.config to set the culture of my web application:
<globalization uiCulture="fr-CA" culture="fr-CA"/>
Problem: when my computer is set to another culture for example en-UK, my application is taking that culture instead of the one i set in the web.config.
Your site might be honoring the browser's stated language preference.
Check the Language settings in the browser, and try setting enableClientBasedCulture in your web.config to false, per this MSDN article.
Also worth making sure you try other basic troubleshooting steps, like resetting IIS (assuming you're not using the built-in Visual Studio development web server).
If those steps fail, I would roll up my sleeves and try some serious debugging. It's possible something else is overriding your setting, or that ASP.NET isn't finding your .resx resource file.
Try overriding the InitializeCulture method on a page and hardcoding the language there (assuming you're using Webforms). That will also let you set a breakpoint while the page is loading and check what the UICulture is set to.
If the cultures are getting set properly, I'd look to make sure everything is set up correctly with your .resx. Those things can be a pain to get configured in my experience.
It might be a good idea to set up a simple HelloWorld demo app to try to reproduce and isolate the problem. Here's a decent walk-through so you can check your setup steps.

Button url caching Dynamics CRM 4 issue

I have added a custom button, with url + javascript by chaning the isv xml file, as described on
http://msdn.microsoft.com/en-us/library/cc150860.aspx
and all works fine. However, when I try and replace the file in the /ISV/ folder, it behaves the same as the original copy, I assume this is caching related. However, if I access the file from outside the CRM that is http://server/ISV/file.htm it has the latest and correct version. How do I get around this caching issue.
Thanks
So your ISV Option points to "/ISV/file.htm"? I think in the past I've noticed CRM's IIS site caching static files for 3 days. What I would do is when you replace your file.htm in your ISV folder, also update the ISV.config:
So change it to point to "/ISV/file.htm?vers=00001" and then increment each time you update the file.

Categories

Resources