Blog Categories

Subscribe to RSS feed


Custom SharePoint List Forms. The C# way… (Part 3)

According to the current implementation you will get an error when you click on Attach File link. I guess most of you have seen this dialog box some time or the other after customizing the edit or new forms for a list.


The problem:

The JavaScript is trying to find the element “part1” (which is the ID of the table which has all the field controls) and though we have set the ID of that table to “part1”, the JavaScript does not find the element.

The cause:

Since we have rendered the input table (Table which holds all the field controls) as a server control, the rendered table has the ID which consists of all the container ID’s and then the ID “part1” that we have set.

The ID is in the format ctl0$ctl1$part1 and so the JavaScript does not find the required element.

The solution:

* This solution applies to a custom ASPX page SharePoint list form.

Since you cannot set the ClientID property of the server control, we create a new class inheriting from Table class. In the new class we override the ClientID property and in its accessor we return the value of the ID property.

public override string ClientID
return base.ID;

Do the same for the TableRow class.

The next step is to use these classes where ever you are using the Table and TableRow classes. This will ensure that the ID you set in your code, is the ID that is set in the output Html element. But there is an added responsibility while coding, and that is to ensure the ID’s that you set are unique.

This will get rid of that dialog box.

Leave a Reply