Vorsicht zu dem Beitrag zuvor. Wenn man dann Werte ausliest aus dem HiddenField, sollte man bzgl. SQL injection oder codegefährdeten Elementen die Werte validieren. Denn im Grunde wäre es ein sehr leichtes, Werte abzuändern und damit Schaden zu verursachen. Ist eine gute Methode, aber mit Vorsicht zu geniessen, wie alles was mit JavaScript zu tun hat.
Attention to the post before. When reading out values from the HiddenField, you should be aware of sql injection or code harming elements. That means validate the values read out. Basically it would be very easy to manipulate the values and harm your application. The described method is a good one, but take care, like you always should, when working with javascript.
Mittwoch, 21. Oktober 2009
Dienstag, 13. Oktober 2009
Javascript & .NET
Dieser Post ist nur ein kleiner Tipp, für alle, die sich mit Javascript Cookies schwer tun und gerne Javascript mit .Net Technologie verbinden. I hatte die Aufgabe in einer Applikation im Front-End viel Javascript zu verwenden und es anschliessend im Back-End zu verarbeiten und das über mehrere Postbacks. Meine Lösung war, Werte des Javascripts in einem .Net hidden-field zu speichern, dann über .Net auszulesen und weiterzuverarbeiten, sei es in einer Session, bzw. Datenbank. Somit erreicht man viel clientseitige Funktionalität ohne .Net Postbacks, mit .Net Vorzügen bei einem Postback.
This post is just a little hint for all people, who find javascript cookie handling hard to do and would like to combine it with .Net technology. My job was to include into the front-end a lot of javascript and then working with it in the back-end through multiple post-backs. My solution was, to store the javascript values in a .Net hidden-field and then to read it out through the .Net technology to proceed in storing in a database or session. The pro of this way is, that you have a lot of client-side functionality without .Net post-backs, with the advantage of .Net when performing a post-back.
This post is just a little hint for all people, who find javascript cookie handling hard to do and would like to combine it with .Net technology. My job was to include into the front-end a lot of javascript and then working with it in the back-end through multiple post-backs. My solution was, to store the javascript values in a .Net hidden-field and then to read it out through the .Net technology to proceed in storing in a database or session. The pro of this way is, that you have a lot of client-side functionality without .Net post-backs, with the advantage of .Net when performing a post-back.
Umbraco certified

Nachdem ich jetzt 3 Jahre mit Umbraco arbeite und schon den Level 2 Kurs besuchte, habe ich die Zertifizierung gemacht und darf mich ab nun "Umbraco Certified Professional" nennen. Zertifizierung beinhaltete Level 1 und 2.
After working with Umbraco for 3 years and participating in the level 2 course, I decided to do the certification and can call myself now an "Umbraco Certified Professional". My certification was level 1 and 2.
Montag, 10. August 2009
ContentXXL Suche funktioniert nicht - search does not work
Wenn Sie das Problem haben, dass das Suchmodul nicht korrekt funktioniert im ContentXXL, dann kann es an Datenbankeinstellungen liegen. Bei jedem Suchbegriff gibt er immer eine "no results" Ausgabe an. Dann bitte den "Volltextindex" bei den Tabellen aktivieren, welche durchsucht werden sollen.
If you have the problem, that the search-module in ContentXXL does not work properly, then there reason for that could be database settings. If every keyword outputs the "no result" page, then please check the "fulltextindex" in your SQL db on the tables, where the search result will happen.
If you have the problem, that the search-module in ContentXXL does not work properly, then there reason for that could be database settings. If every keyword outputs the "no result" page, then please check the "fulltextindex" in your SQL db on the tables, where the search result will happen.
Freitag, 7. August 2009
Events im Page_Load abfangen - catch events in page_load
Manchmal könnte man einige Informationen einen Events schon im Page_Load benötigen. Hierzu kann man folgenden Code verwenden, damit dies funktioniert.
Sometimes you might need information of an event in the Page_Load. You can use this code to achieve this:
Page_Init
MyButton.OnClientClick = GetPostBackEventReference(MyButton);
Page_Load
string eventTarget = Request["__EVENTTARGET"];
if (!string.IsNullOrEmpty(eventTarget))
{
string[] arrNameParts = eventTarget.Split(Convert.ToChar("$"));
string strButtonName = arrNameParts[arrNameParts.Length - 1];
if(strButtonName == "MyButton")
Response.Write("Works");
MyButton_Click(null,null);
}
Der MyButton_Click event wird dann ausführen, was zu dem Button-Click gehört und somit wurde im Page_Load bereits verarbeitet.
The MyButton_Click event will then raise, what means, that the button-click already happend in Page_Load.
Sometimes you might need information of an event in the Page_Load. You can use this code to achieve this:
Page_Init
MyButton.OnClientClick = GetPostBackEventReference(MyButton);
Page_Load
string eventTarget = Request["__EVENTTARGET"];
if (!string.IsNullOrEmpty(eventTarget))
{
string[] arrNameParts = eventTarget.Split(Convert.ToChar("$"));
string strButtonName = arrNameParts[arrNameParts.Length - 1];
if(strButtonName == "MyButton")
Response.Write("Works");
MyButton_Click(null,null);
}
Der MyButton_Click event wird dann ausführen, was zu dem Button-Click gehört und somit wurde im Page_Load bereits verarbeitet.
The MyButton_Click event will then raise, what means, that the button-click already happend in Page_Load.
Donnerstag, 6. August 2009
Caching und Tracking - caching and tracking
Manchmal taucht das Problem auf, dass man gerne Seiten, welche gecached werden tracken will. Problem ist, wie kommt man an die Mischung aus gecachedten und aktuellen Daten?
Hier habe ich den Workaround wie folgt erledigt.
Per Javascript werden für die Seite relevante und gecachedte Daten als Querystring an die URL eines Imagefiles angehängt, welches allerdings auf eine aspx oder php oder jsp Seite verweist. In dieser (bei jedem Aufruf trotz Cache) Seite werden dann aktuelle Daten und Datenbankeintrag ausgeführt sowie Daten aus dem Querystring übernommen. Im Grunde ist es ein IFrame per Imagetag.
Sometimes you might have the problem, that you want to track cached pages. The issue is, how do you get to the mix of cached and runtime data?
I used a kind of work-around to achieve this.
Via javascript you get to the cached (for each tracking item equal) data in the page and then you add those as a query-string to the URL of an image-file that has been added and pointing to a aspx, php or jsp file. In this file you can access the database and enter all runtime data and the query-string data. Basically it is a kind of Iframe made with an image-tag.
<img src="myFile/Log.aspx" border="0" height="1" width="1" />
Im Log.aspx werden dann alle Daten in die Datenbank abgefüllt inkl. Datum, welches dort aktuell ist. Dieser Imagetag kann in jede gechachedte Seite eingefügt werden.
The Log.aspx then runs the database insert with current datetime included, which will be always the runtime one. This image-tag can be inserted to any cached page.
WICHTIG! Kein javascript Datum übergeben, denn dann bekommt man die Clientrechnerzeit, welche durch individuelle Einstellung und Zeitzone stark variiert.
IMPORTANT! Do not enter the javascript datetime, because then you get the client-time, that can differ because of individual settings and time-zones.
Hier habe ich den Workaround wie folgt erledigt.
Per Javascript werden für die Seite relevante und gecachedte Daten als Querystring an die URL eines Imagefiles angehängt, welches allerdings auf eine aspx oder php oder jsp Seite verweist. In dieser (bei jedem Aufruf trotz Cache) Seite werden dann aktuelle Daten und Datenbankeintrag ausgeführt sowie Daten aus dem Querystring übernommen. Im Grunde ist es ein IFrame per Imagetag.
Sometimes you might have the problem, that you want to track cached pages. The issue is, how do you get to the mix of cached and runtime data?
I used a kind of work-around to achieve this.
Via javascript you get to the cached (for each tracking item equal) data in the page and then you add those as a query-string to the URL of an image-file that has been added and pointing to a aspx, php or jsp file. In this file you can access the database and enter all runtime data and the query-string data. Basically it is a kind of Iframe made with an image-tag.
<img src="myFile/Log.aspx" border="0" height="1" width="1" />
Im Log.aspx werden dann alle Daten in die Datenbank abgefüllt inkl. Datum, welches dort aktuell ist. Dieser Imagetag kann in jede gechachedte Seite eingefügt werden.
The Log.aspx then runs the database insert with current datetime included, which will be always the runtime one. This image-tag can be inserted to any cached page.
WICHTIG! Kein javascript Datum übergeben, denn dann bekommt man die Clientrechnerzeit, welche durch individuelle Einstellung und Zeitzone stark variiert.
IMPORTANT! Do not enter the javascript datetime, because then you get the client-time, that can differ because of individual settings and time-zones.
margin: 0pt auto; funktioniert nicht - does not work
Sie haben ein Problem, dass der CSS Befehl margin: 0pt auto; beim Internet Explorer nicht funktioniert? Egal wie man es anstellt, es will einfach den Layer nicht zentrieren. Das liegt an der Formatierung der kompletten HTML Seite. Hierzu bitte folgendes ändern. Standard <html> Tag ersetzen durch:
<?xml version="1.0" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
You have a problem with the CSS coding margin: 0pt auto; in Internet Explorer? No matter what you do, it won't center your layer. The reason for this might be the format of the whole HTML template. Just replace the basic <html> tag with:
<?xml version="1.0" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
<?xml version="1.0" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
You have a problem with the CSS coding margin: 0pt auto; in Internet Explorer? No matter what you do, it won't center your layer. The reason for this might be the format of the whole HTML template. Just replace the basic <html> tag with:
<?xml version="1.0" ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
Dienstag, 4. August 2009
Doppelter Content - Double content
Ein eigenartiger Fehler machte mir ein paar Stunden zu schaffen. Hierbei wurde bei einer Navigation ein Item doppelt angezeigt, ohne dass dieser im Quellcode ersichtlich war. Er wurde nur vom Internet Explorer verdoppelt und dann auch nur, wenn man aus dem ContentXXL ausgeloggt war. Grund hierfür ist die Standardeinstellung der HTML Definition in ContentXXL. Hierbei unter Portalsettings bei Angepasster Doctype diesen individuell einstellen mit <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">. Danach funktionierte alles tadellos.
I had a strange error that I had to spent some time on. One item in my navigation got displayed twice without appearing in the source-code. It was just displayed when using Internet Explorer and when being logged off ContentXXL. Reason for this error is the standard definition of HTML in ContentXXL. To avoid this error, you need to set the Doctype in the portal-settings individually to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">. Then it works.
I had a strange error that I had to spent some time on. One item in my navigation got displayed twice without appearing in the source-code. It was just displayed when using Internet Explorer and when being logged off ContentXXL. Reason for this error is the standard definition of HTML in ContentXXL. To avoid this error, you need to set the Doctype in the portal-settings individually to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">. Then it works.

Montag, 27. Juli 2009
Real Ajax - richtiges Ajax
Wer im Visual Studio das UpdatePanel in Verbindung mit Ajax Requests verwendet, weiss oft nicht, dass der eigentliche Traffic, welcher durch Ajax vermindert werden soll, gar nicht im eigentlichen Umfang vermindert wird. Wie kommt das? Das UpdatePanel vom Visual Studio führt immer einen Request der ganzen Seite aus. Gut sichtbar mit dem Firebug vom FireFox. Hier kann man sehen, dass bei einem auslösen eines Request die gesamte Seite neu geladen wird. Nicht so wenn man einen Ajax Request mit einem Webservice kombiniert. Hierbei programmiert man ein JavaScript selbst, das wiederum eine Methode eines Webservice aufruft. Was man auf die Seite einbindet ist der .NET ScriptManager und man führt die selbstgeschriebenen JavaScript Funktionen auf. Wenn man dann die Seite verfolgt sieht man, dass nur ein Request auf die Methode ausgeführt wird.
Im Detail funktioniert das wie folgt:
People, that use the updatepanel for Ajax request in Visual Studio usually do not know, that the traffic, that is supposed to be reduced with Ajax, is not fully reduced. How does this happen? The updatepanel performs always a full page load of the current page using. You can trace this with the FireBug in FireFox. There you can see, that in triggering a request, the whole page is loaded. This is not the case, when you combine self written javascript with a webservice. In this case you develop a javascript on your own, that calls methods of a webservice. What you include in your aspx page is the .NET ScriptManager and you call the self written javascript functions. If you trace this request afterwards you see, that just the requested methods are loaded.
Here is some detailed information on that:
Füge den ScriptManager mit Verweis auf Javascript und Webservice hinzu
Add the ScriptManager with reference to the javascript and webservice
<asp:ScriptManager runat="server" ID="scriptManagerId">
<Scripts>
<asp:ScriptReference Path="MyJavascript.js" />
</Scripts>
<Services> <asp:ServiceReference Path="MyWebservice.asmx" />
</Services>
</asp:ScriptManager>
<asp:Literal ID="output" runat="server" /><br />
<asp:button ID="Button1" onclick="WriteHello()"><br />
Hier ein kurzes "Hello world!" Skript zur Anschauung. Bitte die Funktion im MyJavascript.js speichern
Here a short "hello world!" script to show how it works. Please save this function in the MyJavascript.js file.
function WriteHello()
{
Sample.MyService.WriteHello( SucceededCallback);
}
function SucceededCallback(WriteThis, eventArgs)
{
var OutputElement = document.getElementById("output");
OutputElement.innerHTML = WriteThis;
}
Danach geht es an den Webservice. Hier die Methode einfügen und als MyWebservice.asmx speichern.
Afterwards we create the webservice and enter the method and save it as MyWebservice.asmx.
namespace Sample {
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
public string WriteHello()
{
return "Hello World!";
}
}
}
Das wars eigentlich. Wenn man auf diese Art und Weise ohne UpdatePanel den Ajax Request startet, sieht man im FireBug, dass nur die Methode geladen wird.
This is basically it. If you now perform the Ajax request without the updatepanel, then you see in FireBug, that just the method is loaded.
Im Detail funktioniert das wie folgt:
People, that use the updatepanel for Ajax request in Visual Studio usually do not know, that the traffic, that is supposed to be reduced with Ajax, is not fully reduced. How does this happen? The updatepanel performs always a full page load of the current page using. You can trace this with the FireBug in FireFox. There you can see, that in triggering a request, the whole page is loaded. This is not the case, when you combine self written javascript with a webservice. In this case you develop a javascript on your own, that calls methods of a webservice. What you include in your aspx page is the .NET ScriptManager and you call the self written javascript functions. If you trace this request afterwards you see, that just the requested methods are loaded.
Here is some detailed information on that:
Füge den ScriptManager mit Verweis auf Javascript und Webservice hinzu
Add the ScriptManager with reference to the javascript and webservice
<asp:ScriptManager runat="server" ID="scriptManagerId">
<Scripts>
<asp:ScriptReference Path="MyJavascript.js" />
</Scripts>
<Services> <asp:ServiceReference Path="MyWebservice.asmx" />
</Services>
</asp:ScriptManager>
<asp:Literal ID="output" runat="server" /><br />
<asp:button ID="Button1" onclick="WriteHello()"><br />
Hier ein kurzes "Hello world!" Skript zur Anschauung. Bitte die Funktion im MyJavascript.js speichern
Here a short "hello world!" script to show how it works. Please save this function in the MyJavascript.js file.
function WriteHello()
{
Sample.MyService.WriteHello( SucceededCallback);
}
function SucceededCallback(WriteThis, eventArgs)
{
var OutputElement = document.getElementById("output");
OutputElement.innerHTML = WriteThis;
}
Danach geht es an den Webservice. Hier die Methode einfügen und als MyWebservice.asmx speichern.
Afterwards we create the webservice and enter the method and save it as MyWebservice.asmx.
namespace Sample {
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class MyService : System.Web.Services.WebService
{
[WebMethod]
public string WriteHello()
{
return "Hello World!";
}
}
}
Das wars eigentlich. Wenn man auf diese Art und Weise ohne UpdatePanel den Ajax Request startet, sieht man im FireBug, dass nur die Methode geladen wird.
This is basically it. If you now perform the Ajax request without the updatepanel, then you see in FireBug, that just the method is loaded.
Freitag, 10. Juli 2009
Content XXL Context.Items
Welche Werte kann man aus der Context.Items im ContentXXL auslesen? Hier eine Liste.
Which values can you get from the Context.Items in ContentXXL? Here is a list.
mailcontacttabid
user_contactid
enableeditmode
user_usersetting2
user_usersetting3
user_usersetting1
portaltitle
user_usersetting4
user_usersetting5
tellafriendbackurl
cuid
htmlversion
theme
useremail
subculture
applicationpath
relatedbaseobject
username
AspSessionIDManagerInitializeRequestCalled
loginalias
pagebaseurl
AspSession
charset
tellafriendpreview
portalid
defaultlanguage
currentDevice
baseurl
isNamedUrl
PortalSettings
culture
pathinfo
tellafriendtitle
isindetailview
lang
relatedbasetab
tabid
usertrackerdisabled
pagename
Which values can you get from the Context.Items in ContentXXL? Here is a list.
mailcontacttabid
user_contactid
enableeditmode
user_usersetting2
user_usersetting3
user_usersetting1
portaltitle
user_usersetting4
user_usersetting5
tellafriendbackurl
cuid
htmlversion
theme
useremail
subculture
applicationpath
relatedbaseobject
username
AspSessionIDManagerInitializeRequestCalled
loginalias
pagebaseurl
AspSession
charset
tellafriendpreview
portalid
defaultlanguage
currentDevice
baseurl
isNamedUrl
PortalSettings
culture
pathinfo
tellafriendtitle
isindetailview
lang
relatedbasetab
tabid
usertrackerdisabled
pagename
Abonnieren
Posts (Atom)