Udostępnij za pośrednictwem


AjaxOptions.UpdateTargetId Property

Gets or sets the ID of the DOM element to update by using the response from the server.

Namespace:  System.Web.Mvc.Ajax
Assembly:  System.Web.Mvc (in System.Web.Mvc.dll)

Syntax

'Declaration
Public Property UpdateTargetId As String
    Get
    Set
public string UpdateTargetId { get; set; }
public:
property String^ UpdateTargetId {
    String^ get ();
    void set (String^ value);
}

Property Value

Type: System.String
The ID of the DOM element to update.

Remarks

The following example how to use the UpdateTargetId property to set the ID of the elements that are used to display the status message and to enter text.

<h2><%= Html.Encode(ViewData("Message")) %></h2>
<p>
  Page Rendered: <%= DateTime.Now.ToLongTimeString() %>
</p>
<span id="status">No Status</span>
<br />   
<%=Ajax.ActionLink("Update Status", "GetStatus", New AjaxOptions With {.UpdateTargetId = "status"})%>
<br /><br />
<% Using (Ajax.BeginForm("UpdateForm", New AjaxOptions With {.UpdateTargetId = "textEntered"}))%>
  <%= Html.TextBox("textBox1","Enter text")%>  
  <input type="submit" value="Submit"/>
  <br />
  <span id="textEntered">Nothing Entered</span>
<% End Using%>
<h2><%= Html.Encode(ViewData["Message"]) %></h2>
<p>
    Page Rendered: <%= DateTime.Now.ToLongTimeString() %>
</p>
<span id="status">No Status</span>
<br />   
<%= Ajax.ActionLink("Update Status", "GetStatus", new AjaxOptions{UpdateTargetId="status" }) %>
<br /><br />
<% using(Ajax.BeginForm("UpdateForm", new AjaxOptions{UpdateTargetId="textEntered"})) { %>
  <%= Html.TextBox("textBox1","Enter text")%>  
  <input type="submit" value="Submit"/><br />
  <span id="textEntered">Nothing Entered</span>
<% } %>

See Also

Reference

AjaxOptions Class

System.Web.Mvc.Ajax Namespace