Orchard custom controller, crazy bug ?

Topics: General
Dec 19, 2012 at 4:26 PM
Edited Dec 19, 2012 at 4:34 PM

hello people,

I've got a strange error in my module. I will not be on it why

What I have done:

Creating custom controller, with HTTP-Post function for deleting items.

Also I have create a content that conatins a list of items, and every item has a delete button:

 

@using(Html.BeginForm("DeleteImage", "Einsatz", new { id =  Model.ContentId, imageId = bilder.Id, area = "Feuerwehr.Base" })) {
<button type="submit">Delete</button> }

 

The problem is, I can delete all the items, but not the first item. But the html generated code looks like good:

 

<div class="editor-label">Missions</div>
    <table class="items" summary="This is a table of the customers in your application">
        <colgroup>
            <col id="Col1" />
            <col id="Col2" />
            <col id="Col3" />
        </colgroup>
        <thead>
            <tr>
                <th scope="col"> ?</th>
                <th scope="col">Mission</th>
                <th scope="col">Public</th>
                <th scope="col">Option</th>
            </tr>
        </thead>
        <tr>
            <td>1</td>
            <td><img  src="/OrchardLocal/Media/Default/Uploads/230e9639-d48a-4f0c-922c-1793b0b999c9/DSC02577.JPG" class="smallPreviewImage" /></td>
            
            <td>False</td>

            <td>
            <fieldset>


		<!-- NOT WORK -->
		<form action="/OrchardLocal/Feuerwehr.Base/Einsatz/DeleteImage/17?imageId=1" method="post">

			<button type="submit">Delete</button>
		</form>
            </fieldset>
            </td>
        </tr>
        <tr>
            <td>12</td>
            <td><img  src="/OrchardLocal/Media/Default/Uploads/230e9639-d48a-4f0c-922c-1793b0b999c9//DSC02598.JPG" class="smallPreviewImage" /></td>
            
            <td>False</td>

            <td>
            <fieldset>
		<!-- WORKE FINE -->
		<form action="/OrchardLocal/Feuerwehr.Base/Einsatz/DeleteImage/17?imageId=12" method="post">                    

			<button type="submit">Delete</button>
		</form>
            </fieldset>
            </td>
        </tr>
</table>

If I look on the request log, I see, that if I click the first item he do only a redirect and not calling the controller function.But funny, if i call the secound item and alle follow items, it will be work ! But only the first item not ...

Have anyone an idea, why this not working ?


If you are interested see the error live, I can send you the module it by mail.


I apologize for my English... Hacky

Coordinator
Dec 19, 2012 at 6:22 PM

You have nested forms. The second one works because the browser thinks the </form> tag of your first form was the closing tag for the outer form.