Saturday 25 July 2009

ASP.NET IIS Firefox authentication required problem



Today, I had problem with running my asp.net project while using Firefox. It asked me to enter username and password to see the page. However, I tried all the passwords and none of them worked. This problem never occurred before, so I googled and finally found the solution.

  1. Enter about:config at firefox address bar. (You will see warning message indicating that these are advanced settings that may affect the browser security and stability)
  2. Click "I'll be care, I promise" button
  3. Search network.automatic-ntlm-auth.trusted-uris at filter. (Only one entry will be appear)
  4. Double click the entry and type localhost.
  5. Save it and reload your web page then DONE!
Here's the original link from ASP.net forum.



Friday 24 July 2009

Accessing Posted Data in ASP.NET

There are two ways to access data using Page.PreviousPage in asp.net

1. Using FindControl function

string username = ((TextBox)PreviousPage.FindControl("tbxUsername")).Text;

2. Using Strongly Typed Data
I personally like this one because I don't care about what the control name is. Also, no typo mistakes will be made.
Here is how to make a strongly typed data

public string UserName
{
get{return tbxUsername.Text;}
}

Also we have to set the code below at the page that receives the posted data.

<%@ PreviousPageType VirtualPath="~/pageName.aspx" %>


Last step, you have to rebuild in order for page to see the property in receiver page.



Wednesday 22 July 2009

ASP.NET CustomValidator with Javascript

To use CustomValidator with client side javascript validation, we need to implement a javascript with two parameters.


function YourFunctionName(source, arguments)



Set property ClientValidationFunction to the name of your javascript at CustomValidator control.

arguments.Value is the data that we will be validated.

arguments.IsValid indicates validation success or failure.

If the validation is passed, we set arguments.IsValid = true. False otherwise.

Tuesday 14 July 2009

Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1

Last Friday was the official day that Silverlight 3 released. I was about to go home on Friday and don't know why something came to my mind that it's time to check Silverlight's website. Boom! SL 3 is released.


Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1

Saturday 11 July 2009

Using Output Caching to Enhance Web Site Performance

There are 2types of caching for ASP.NET

1. Configuring Page-Level Caching
copy the code below to aspx html source page

<%@ OutputCache Duration="15" VaryByParam="none" %>

Duration means the duration of the cache. In this case, it will cache for 15 seconds.











the name "AppCache1" will be used to the pages that you want to have cache. You can have different kinds of cache options by just adding another profiles like the code below




what we have to do in each of our page is add the code below

<%@ OutputCache CacheProfile="AppCache1" VaryByParam="none" %>

Note: the name of the CacheProfile is the name you set in outputCacheProfiles in web.config.


The attribute VaryByParam is used for caching parameters (eg. querystring) of a page.
example:

<%@ OutputCache Location="Server" Duration="60" VaryByParam="Color" %>


Here we have a param called "Color". (http://mysite/mypage.aspx?Color=red)
When user goes to the page wtih Color=red, it caches the page with param Color=red for specific duration according to our setting.

If we specify the VaryByParam parameter, any new value will be cached. For cached value, it loads data from cache.


Here's the detail explanation of VaryByParam from Microsoft MSDN
==================================
The @ OutputCache directive requires you to set the VaryByParam attribute, which until you now you have set to "none". The VaryByParam attribute enables you to configure caching so that ASP.NET stores different versions of a page depending on parameters such as query strings, form post values, request headers, and so on.

For example, you can use cache parameters in a page that displays weather conditions for select cities, where the weather data is refreshed only every three hours. In this scenario, you want to cache a separate version of the page for each city. You can do so by setting the cache parameter to vary by a query string parameter.
==================================


If you wish to study all the details on your own see here

PDF Split and Merge



PDF Split and Merge is an open source software that allows us to split PDF files into multiple files.

When you installed the program and you see missing javaw.exe, please download Java Virtual Machine

Friday 10 July 2009

Silverlight 3 Element to Element Binding




We don't have to create tons of events for updating values, texts to different controls.

The code below does it all. No additional coding inside cs file.
{Binding Value, Mode=OneWay, ElementName="MyControlxName"}

It's like the old binding style except that we have ElementName to tell the compiler that we want to bind the property to the element MyControlxName's Value property.


Thursday 9 July 2009

ASP.NET Dynamic Compilation

Unlike ASP, ASP.NET doesn't have to compile each and every time it is requested. An ASP.NET page is compiled only once when an application is modified. If it is not modified, the Framework will look for the directory


\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files


to load the compiled dll.


However, if a site contains thousands of pages. Having Framework to precompile everything and store in the temp folder isn't a good choice. Here the way to chose if you want the compiler to precompile or not.
Adding CompilationMode attribute inside the <%@ Page Language="C#" %> tag at html source code view.
The attribute has Always, Auto, and Never. I believe the default is Auto :)



Wednesday 8 July 2009

Friday 3 July 2009

Running PHP in IIS 5.1, IIS7.0

Here's the tutorial link that I followed.

IIS 5.1
Link 1

IIS 7.0
Link 1
Link 2