January 22nd, 2010
No Comments
In my C# Web Application, I have a GridView with a TemplatField. Within the TemplateField is a HyperLink control. My goal is to bind this HyperLink control using Custom Expression Binding. I want the NavigateUrl to point to:
Visit.aspx?name=XXX
XXX in the link above is the database column name. My first instinct is to use the Custom Expression Binding method called Eval() to bind this column. An example of the use of this semi-working method below should be included in the <asp:HyperLink> control.
<asp:HyperLink NavigateUrl=’<%# “Visit.aspx?name=” + Eval(“name”) %>’></asp:HyperLink>
I say this semi-works because the evaulted “name” must not contain any special characters like the ampersand (&). Then the next idea is trying to encode the Eval(“name”). This however was not entirely clear. After researching, I found the following solution.
<asp:HyperLink NavigateUrl=’<%# “Visit.aspx?name=” + HttpUtility.UrlEncode(Eval(“name”).ToString()) %>’></asp:HyperLink>
And this is how to properly encode a hyperlink url that is bound using Custom Expression Binding. Though this may not be visible from the browser, the web page source will reveal that the ampersand (&) has been replaced with %26, which is its equivalent.
The last step on the following page my require decoding the encoded url.
January 12th, 2010
No Comments
To enable the IIS Manager in Windows 7, you’ll need to follow the following steps:
- From Windows 7’s Start Menu, search for ‘Turn Windows features on or off’ or find the application from the Control Panel.
- To enable IIS Management Console, browse to: Internet Information Services > Web Management Tools > IIS Management Console. Check the final checkbox.
- Click the OK button and try searching for ‘Internet Information Services (IIS) Manager’ from the Start Menu. If it appears, this means that the installation worked.
January 11th, 2010
No Comments
While taking over a C# Web Application that had been migrated to work with Visual Studio 2008 (originally developed and migrated from Visual Studio .NET 2003), I occasionally ran into issues while trying to publish the web application to the production server (or any server for that matter). In the output log, there were multiple error messages, all stating:
Unable to add ‘XXX.aspx’ to the Web site. Unable to add file ‘XXX.aspx’. Access is denied.
Each XXX.aspx would be a different files. What I learned after browsing and searching Google is to make sure the files on the production (or target) server are not marked as Read Only. The solution was to:
- Go to the Publish directory
- Highlight all files and folders
- Right click and select Properties
- Make sure the Read-only attribute checkbox is unchecked (white and not gray or checked)
References:
http://forums.asp.net/p/1074678/3431238.aspx#3431238