Introduction

I have spent numerous hours searching for solutions to programming problems that I think should have a more accessible solution. This blog will contain my experiences and the solutions that I found. Your comments are welcome of course.

Wednesday, August 18, 2010

Content vs Compile

I ran into this problem a few weeks ago while writing a class in one of my ASP.Net applications. For some reason, the Visual Studio 2010 environment considers any class you add to the solution as "content". What content means is that the code doesn't compile. This also means that you can not access the code using intelli-sense nor add references to the class in other parts of your code. It can be extremely frustrating to debug.

To solve the problem, select the class in question and then change "Build Action" in the properties window of that class to "Compile" instead of content.

Wednesday, May 26, 2010

ASP.NET C#: Add Confirm Message to GridView Delete Button

A good feature to have as part of any GridView is the ability to delete an item from the grid.
If the grid is dynamically linked to a DataSet then the buttons must be generated at run-time. This causes a problem if you want to perform some kind of confirmation to the delete operation so that the user doesn't simply delete an item by mistake.

The confirmation is easily achieved using an AJAX Tool Kit Extender control called the Confirm Button Extender Control. The problem is getting the control associated with the dynamically generated buttons.

The only way to achieve this would be to actually include the Confirm Button Extender Control definition as part of your template definition for the Delete button.

the following code demonstrates:
<Columns>
<asp:TemplateField HeaderText="Delete Item">
<ItemTemplate>
<asp:LinkButton
ID="delButton"
runat="server"
OnClick="delButton_Click">Delete</asp:LinkButton>
<asp:ConfirmButtonExtender
ID="cbeDelete"
runat="server"
TargetControlID="delButton"
ConfirmText="Are you sure you want to delete this item"
ConfirmOnFormSubmit="true"></asp:ConfirmButtonExtender>
</ItemTemplate>
</asp:TemplateField>
</Columns>