
Because I want to show default value in my create page. and in the create page code was used Html.TextBox and model to generate the input box.
Since it was used model to generate the code and we also can use model to set the default value as well.
Below example code are showing how set the default value in model:
public class Category
{
public int ID { get; set; }
public string Name { get; set; }
public DateTime CreateDate { get; set; }
}

I had install Rights module inside my application. The Rights module itself wouldn’t auto integrate with the controller.
So I need to integrate myself, at each of the controller we need to add 2 extra function they are:
public function filters() {
return array(
'accessControl',
);
}
and
public function accessRules() {
return array(
array('allow',
'action' => array('Index'),
'users' => array('@'),
),
);
}
Posted by
chevrons in
Yii

I am making a little code to test the functionality server with MSSQL Database connection. The test code was develop with asp.net C#.
If the script successful connect with MSSQL Database it will display message like below:
TESTS COMPLETED SUCCESSFULLY!.
Else, it will display
TESTS FAILED!
Server script:

By default, IIS and ASP.NET hide detailed error information to prevent revealing sensitive information about your web application.

Sometimes we need to see error details (think shared hosting) to debug our coding.
To display the error message. Add these entries to your web.config file to disable generic errors:

Have 2 methods to do it.
Method 1:
echo eval('return $'. $string . ';');
And another method as below:
$counter = 1;
$button1 = "Hello PHP";
$printbutton = ${'button' . $counter};
echo $printbutton
The Method 2 example will print out
Hello PHP
Posted by
chevrons in
PHP

Installing PHP itself is quite straightforward; the difficulty lies in configuring IIS to use it! There are a number of programs contained within the standard Win 32 distribution, for example it contains two versions of the PHP interpreter that we can use with IIS. The first is a DLL (Dynamic Link Library) that contains an ISAPI module for IIS. This module will run as a persistent interpreter in IIS, one that does not need to be called externally, so in theory should provide the best performance.
In reality, I have found the ISAPI module to be unstable with PHP 5 and IIS on Windows, often causing access violations. These issues will most likely be resolved in time, and may be by the time that you are reading this.
The second version, a standard C executable, is the one that we will be using. This runs under IIS as an external CGI (Common Gateway Interface) call, similar to the way Perl/CGI works, so as a result is not as quick as the ISAPI module, but it is very stable. In the trade-off between speed and stability, we should always favour stability for a live production server.
Installing Steps
-Create a folder called PHP on the C drive root
-Unzip the contents of the zip file you downloaded for PHP 5 into C:\PHP
-In C:\PHP, rename php.ini-dist to php.ini
-You may want to add C:\PHP onto the system path variable, as you did for MySQL in the previous section
That’s it! Now onto configuring PHP 5.
Posted by
chevrons in
PHP

After add extra field inside the Model. I get an error message when I run the application.
The error message as below:
The model backing the 'MyContext' context has changed since the database was created.
It was because the Model was different with Database field. And now, you need rebuild the Database structure again.
The solution is:
1. Open Package Manager Console from Tools -> Libraray Package Manager -> Package Manager Console
2. PM> Enable-Migrations -ContextTypeName <TheDatabaseName>
3. Set AutomaticMigrationsEnabled=true, from Migrations folder of Configuration file
4. PM> Add-Migration InitialCreate
5. PM> Update-Database
Now try run the application again. it will work fine and updated to the new Model.
Or you can use
another way to solve the problem.

Because I did delete the DB file and now I get an error message when I run the application. I expected it was the DB file was deleted by me and it didn’t help me rebuild the DB.
To solve this issue, we need stop and delete the Database with follwing step:
1. Open Package Manager Console from Tools -> Libraray Package Manager -> Package Manager Console
2. Stop local DB with command: PM > sqllocaldb.exe stop v11.0
3. and then delete it PM > sqllocaldb.exe delete v11.0
Now try run the application again. it will work fine again.