Skip to content Skip to sidebar Skip to footer

Ajax.actionlink Insert After Header In A Table?

I have a that has a header row. I'm trying to add an item under the header row, but there seems to be no way to describe this intent to the ActionLink function. Inser

Solution 1:

AFAIK there is no way to achieve such behavior with only properties of the AjaxOptions class. One way would be to subscribe for the OnSuccess method and do the insertion manually:

@Ajax.ActionLink("click me", "someAction", newAjaxOptions { OnSuccess = "success" })

and the success function:

<scripttype="text/javascript">functionsuccess(result) {
        $('table').after('th').append(result);
    }
</script>

or if you are using MicrosoftAjax you need to call the get_data method to fetch the returned result from the ajax call:

functionsuccess(result) {
    $('tableid').after('th').append(result.get_data());
}

Solution 2:

Use Jquery.

$("tableid").after("<th></th>").append("whatever");

Post a Comment for "Ajax.actionlink Insert After Header In A Table?"