25 May 2009

ASP.NET How To access Master Page Variables Class Members C#.NET

Sometimes we need to access to a variable in master page file.
For example I need to change the body onload event in html.

In the asp.net file, we simply cast our master page as its class name.

in master page aspx we add the code below.

<body onload="<%=myloadstr %>" >

in master page cs code we add the code below.
we declare it as public to access the variable.

public string myloadstr = "";

And add the code below in your asp.net cs source file.

((myMasterPage)this.Master).myloadstr = "here some javascript for load";

myMasterPage is the name of my masterpage class. We cast our asp.net page its masterpage, with "this.Master".

22 May 2009

Run PHP On Local Machine

When I want to develop a php website, it is always be hard to run and test the php code on local machine.
After I search how to run php on local machine, I found an awesome tool for this.

XAMPP is a great open source software that helps you run php on local, and also it runs MySQL Server service, Filezilla FTP.

Simply download xampp and install it, I select the run apache as service option.

By its default, it installs into C:\xampp directory,
you can copy your php files into C:\xampp\htdocs directory, and open in your browser.