Embed Facebook Like Button – Right Align with css and Settings

by andrej 9. January 2011 18:28

If you want to embed a Facebook Like button and you want it to align to the right here is a fix with css only: First, get the embed code from facebook: http://developers.facebook.com/docs/reference/plugins/like If you embed the XFBML code and the button is smaller than the size you specified, the button will always align to the left. There is nothing you really can do about it due to the iframe structure of the embed code. However, if you specify the width of the like button to be 0, the iframe will always be almost the size of the button, which means you can align it whichever way you want. There in the settings make sure to select width to equal 0. This leads to the facebook like button element always being the size it actually is. Which allows you to position whichever way you want, to the right for example. However there is one little trick, you still have to pull: There is a 15 pixel margin to the right of the element. You can align the button exactly to the right by giving your parent html element following css style: position:relative; right:-15px; The result looks like this:

Javascript in UserControl in UpdatePanel

by Oliver 28. November 2009 15:17

Wenn man weiß, wie es geht, ist alles einfach. Aber JavaScript in UserControls innerhalb eines UpdatePanels funktionstüchtig zu bekommen hatte für mich - bis heute! - immer etwas mit Magie zu tun... Hinzu kam heute, dass ich noch Sys.UI.DomElement-Methoden nutzen wollte (aus der AJAX-Bibliothek). Folgende Versuche habe ich gemacht: 1. Page.ClientScript.RegisterClientScriptBlock(GetType(), "helpful_css_" + ClientID, script, true);2. ScriptManager.RegisterClientScriptBlock(this, GetType(), "helpful_" + ClientID, script, true);3. Page.ClientScript.RegisterStartupScript(GetType(), "helpful_css_" + ClientID, script, true);4. ScriptManager.RegisterStartupScript(this, GetType(), "helpful_css_" + ClientID, script, true); // <-- this is it!   Zu 1. und 3. ist zu sagen, dass sie innerhalb einen UpdatePanels nur nach dem ursprünglichen PageLoad funktionieren, nicht nach einem asynchronen Postback. Also fallen sie raus. Außerdem fallen 1. und 2. weg, weil an der Stelle, an der der hier übergebene JavaScript-Code in die Seite generiert wird, der $Sys-Namespace noch nicht definiert ist (ähnlich wie hier: http://encosia.com/2007/08/16/updated-your-webconfig-but-sys-is-still-undefined/). Bleibt nur 4. Und 4. funktioniert sowohl nach dem initialen PageLoad als auch nach einem async Postback und man kann $Sys verwenden. Wunderbar! 1. oder 2. bleiben allerdings nützlich, wenn man Custom Javascript in die Seite einfügen will, um es weiter unten auf der Seite zu nutzen. Wahlweise kann man natürlich auch die Methode RegisterClientScriptInclude nutzen, um das Javascript in eine eigene Datei auszulagern. Soviel dazu. Oliver

Enum / Flags einfach und sicher definieren

by Oliver 13. November 2009 22:33

Hier (http://blogs.msdn.com/kcwalina/archive/2004/05/18/134208.aspx#5943757) habe ich eine Methode gefunden, wie man einfach und ohne Mathekenntnisse (für einige von uns ;-)) Flag-Enums definiert: .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } enum Color { None = 0, Blue = 1 << 0, Red = 1 << 1, Yellow = 1 << 2, Purple = Blue | Red, Orange = Red | Yellow, } Oliver

CPE (CollapsiblePanelExtender) per JavaScript öffnen

by Oliver 12. November 2009 20:53

Bevor ich noch x Mal durchs Web klicke, hier der Einzeiler: .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: Consolas, "Courier New", Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } hplCatBox.Attributes["onclick"] = "javascript:$find('" + cpeInqCat.BehaviorID + "').expandPanel(new Sys.EventArgs)";

VS2008 Code Snippet zum Repeater-Befuellen

by Stefan 14. September 2009 18:26

Wir befuellen ja haeufig im Frontend einen Repeater. Das einfaedeln der DataSource und das Erstellen und Verknuepfen des EventHandlers fuer ItemDataBound bekommt man mit IntelliSense innerhalb weniger Sekunden hin. Aber wenn man dann den Befuell-Code schreibt, geht es immer wieder los: Wie waren gleich nochmal die ersten 3 Zeilen? Damit ist jetzt Schluss. Einfach die Datei "repeater.snippet" in "Documents/Visual Studio 2008/Code Snippets/Visual C#/My Code Snippets" des Nutzers mit dem man VS ausfuehrt kopieren. Leider zeigt die ReSharper-IntelliSense den Shortcut nicht an, funktionieren tut es trotzdem. Man tippe: rpt [ESC] [TAB] Der Rest versteht sich von selbst: repeater.snippet (1,03 kb)

Configuration mit configSource auslagern - Copy always

by Oliver 5. September 2009 10:01

Eine kleine Notiz für die Zukunft: Wenn man eine Configuration-Section aus einer *.config-Datei in eine eigene Datei auslagert, so wie neulich geschehen für die NHibernate-Konfiguration, dann sollte man die "Copy to Output Directory"-Option auf "Copy Always" setzen: <!-- Lokal eine passende NH.config anlegen --> <hibernate-configuration configSource="NH.config" /> Ansonsten bekommt man nämlich eine der folgenden ähnliche Fehlermeldung: System.Configuration.ConfigurationErrorsException: Die configSource-Datei "NH.config" kann nicht geöffnet werden. (G:\Projects\Camping.Info\Tests\bin\Debug\Tests.dll.config line 12) Oliver

Cache, Autofac und Tests

by Oliver 10. June 2009 10:33

häufige Probleme bei Tests [More]

PowerCommands for VS 2008

by admin 5. March 2008 03:36

Viele schöne Ergänzungen für Visual Studio 2008, Beispiel:   Überblick über die Features Download

VS 2008, Partial Class, Gruppieren

by admin 21. February 2008 05:35

Damit partielle Klassen im Solution Explorer gruppiert dargestellt werden, bedarf es einer kleinen Anpassung in der Projektdatei. Hinzugefügt werden muß das Element "DependentUpon" und schon fügt sich zueinander, was sich fügen soll :-)

Log4Net Konfiguration

by admin 17. February 2008 12:13

Nun habe ich schon x- Mal vergessen, dass log4net die Konfiguration aus einer „app.config“ oder „web.config“ nur dann liest, wenn die Assembly das entsprechende Attribut bekommt: [assembly: log4net.Config.XmlConfigurator(Watch = true)] Und bei einer schnellen Suche in der Dokumentation habe ich diesen Teil, auch schon des öfteren überlesen. Hier nochmal in bunt :-)   (Hoffentlich ist es nun in die grauen Zellen eingebrannt :-)

About Oliver

shades-of-orange.com code blog logo I build web applications using ASP.NET and have a passion for javascript. Enjoy MVC 4 and Orchard CMS, and I do TDD whenever I can. I like clean code. Love to spend time with my wife and our children. My profile on Stack Exchange, a network of free, community-driven Q&A sites

About Anton

shades-of-orange.com code blog logo I'm a software developer at teamaton. I code in C# and work with MVC, Orchard, SpecFlow, Coypu and NHibernate. I enjoy beach volleyball, board games and Coke.