Category Archives: ASP.NET

Injecting Values for Default MVC Model Binding

In a recent project, due to security concerns, we want to encrypt all QueryString values into a single encrypted value before placing the link in web pages, then decrypt it back to individual name/value pairs and pass them to default … Continue reading

Posted in ASP.NET, MVC | Tagged , | Leave a comment

Why the view doesn’t display the new values set in the post back method

In MVC, when you post back any changes, it’s recommended that you follow the PRG (Post-Redirect-Get) pattern to the View page. However, if you want to display the same model data back in the same request, there might be something … Continue reading

Posted in MVC | Tagged | Leave a comment

Src=” causes double page requests

A html tag with src=” (ie img) will cause the browser to try to request that resource at the same URL as the current page, hence causes double requests.

Posted in ASP.NET | Tagged , | Leave a comment

Formatting Dates, Times and Numbers in C#

Good reference (with examples)  http://www.4guysfromrolla.com/articles/111010-1.aspx

Posted in ASP.NET | Tagged , | Leave a comment

Why EntitySet not auto-generated by LINQ-to-SQL?

It turns out the the child table must have a primary key. If not set in database level, that can be set in the *dbml file. Multiple-field primary key works too.

Posted in ASP.NET | Tagged , | Leave a comment

Client-side validator not firing in FF, only in IE

Symptom: For a legacy web app converted from older version of ASP.NET, the client javascript form validation only fires in IE, not in FF. Fix: Change this line in web.config <xhtmlConformance mode=”Legacy”/> to: <xhtmlConformance mode=”Transitional”/>

Posted in ASP.NET | Leave a comment

Tricks using Full Text Search with Chinese content

SQL Full Text Search offers a fuzz logic search. To get desired search result with Chinese content, the following steps have to be followed (among others): Set language for columns (and you can’t mix different language settings for a table): … Continue reading

Posted in ASP.NET, SQL | Tagged | Leave a comment

Using Full Text Search with LINQ

LINQ does not natively support full text search keywords (FREETEXT, CONTAINS etc).  Actually the compiler won’t complain about them but just translate everything to LIKE. Here is the work around: 1. Create a table-valued function that takes in keyword as … Continue reading

Posted in ASP.NET, SQL | Tagged | Leave a comment

LINQ: add association for database views

The LINQ to SQL Designer automatically create association for tables that have foreign keys defined. However for database views, it won’t because there is no foreign keys relationship in views. Manually adding association in the Designer will not create “private … Continue reading

Posted in ASP.NET | Tagged | Leave a comment

ListView paging with dynamic datasource

Binding a Listview with a design time datasource is very convenient,  and you can utilize the default paging function of DataPager. To use a dynamically assigned datasource with minimum code for paging, do this: Method 1: In Page.aspx: <asp:DataPager ID=”DataPager1″ … Continue reading

Posted in ASP.NET | Tagged | Leave a comment