Why does the first alert say undefined? Note that the alert is there and the textbox only appears when i dismiss the alert.

Subsequent “new” click alerts “RowId”. After i dismiss the alert, i see two boxes.

Here is my view with an Ajax.Action link which is InserterAfter.
@Ajax.ActionLink("New", "_New", new { Controller = "Test" }
, new AjaxOptions()
{ InsertionMode = InsertionMode.InsertAfter, UpdateTargetId = "divNew" })
<div id="divNew" />
Here is my partialview.
RowId: @Html.TextBox("RowId")<br />
<script language="javascript">
$(document).ready(function ()
{
alert($('input[name="RowId"]').attr('Id'));
});
</script>
Try the following in your main view:
or throw away
Ajax.*helpers and use plain old jQuery:This being said, if I am not mistaken and if my memory is good, I think I’ve already commented on a similar previous question of yours, but I will repeat it here so that other people can see it as well:
I am seeing people making this mistake over and over again and I think its important to point it out.
P.S: you probably wanted to use
.attr('id')instead of.attr('Id').