views:

1333

answers:

2

I'd like to put a div on my master page that I can update from anywhere in my site with updates. i.e. "recorded updated", "there was an error", etc.

I'm going to style the div differently depending on the type of update. "fail", "success", "info". Basic stuff so far.

So I have several ActionLinks throughout the site and they display their content fine in the updateTarget and I can even have them run fine when I pass OnComplete, OnBegin, etc. functions to them. However, I'd like to be able to send a parameter to that OnBegin function.

Example: .OnBegin="someFunction('fail');"

Any ideas on how to accomplish what I'm doing here?

A: 
 <% string message = "failed"; %>
        <%=Ajax.ActionLink("TestController","TestAction",
new AjaxOptions{OnBegin="myFunction('" + message + "')"}) %>
Marwan Aouida
A: 

You can create an anonimous function, and next call your function with your paramas

<%: Ajax.ActionLink("Text", "ActionName", new { id = item.id }, new AjaxOptions { HttpMethod = "Post", OnComplete = "function(){myFunction(" + item.id.ToString() + ");}" })%>

The script:

    <script type="text/javascript">
    function onDelete(id) {
        alert("hello "+id);
    }
</script>
Juan Carlos