QA@IT
«回答へ戻る

回答を投稿

現象が出ているソースです。
Default.aspx

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Repeater runat="server" ID="aaa">
        <ItemTemplate>
            <asp:TextBox runat="server" ID="bbb" />
        </ItemTemplate>
    </asp:Repeater>
    </form>
</body>
</html>

Default.aspx.vb

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            Return
        End If

        Dim table As New DataTable
        table.Columns.Add(New DataColumn("ccc"))

        For i = 1 To 10
            Dim r As DataRow = table.NewRow
            r("ccc") = i.ToString
            table.Rows.Add(r)
        Next

        Me.aaa.DataSource = table
        Me.aaa.DataBind()
    End Sub

End Class

実行結果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="content-language" content="ja" /><meta http-equiv="content-style-type" content="text/css" /><meta http-equiv="content-script-type" content="text/javascript" /><meta http-equiv="pragma" content="no-cache" /><meta http-equiv="cache-control" content="no-cache" /><meta http-equiv="expires" content="0" /><title>

</title></head>
<body>
    <form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTAzMDE5NjQzD2QWAgIDD2QWAgIBDxYCHgtfIUl0ZW1Db3VudAIKZGT2cAOzJfxpNL5A5ZukofehnvKlWA==" />
</div>

<div>
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCwLHtPKaCALdisw7ArqKzDsCm4zMOwKAjMw7AtmJzDsCtonMOwKXi8w7AvyKzDsClYnMOwLyiMw7BarzwEHb/hvG9W+neVi/ii77N7M=" />
</div>

            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
    </form>

</body>
</html>

希望している結果は

<input name="aaa$ctl00$bbb" type="text" id="aaa_ctl00_bbb" />

なのですが…

現象が出ているソースです。
Default.aspx
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Repeater runat="server" ID="aaa">
        <ItemTemplate>
            <asp:TextBox runat="server" ID="bbb" />
        </ItemTemplate>
    </asp:Repeater>
    </form>
</body>
</html>
```

Default.aspx.vb
```
Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If IsPostBack Then
            Return
        End If

        Dim table As New DataTable
        table.Columns.Add(New DataColumn("ccc"))

        For i = 1 To 10
            Dim r As DataRow = table.NewRow
            r("ccc") = i.ToString
            table.Rows.Add(r)
        Next

        Me.aaa.DataSource = table
        Me.aaa.DataBind()
    End Sub

End Class
```

実行結果
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><meta http-equiv="content-language" content="ja" /><meta http-equiv="content-style-type" content="text/css" /><meta http-equiv="content-script-type" content="text/javascript" /><meta http-equiv="pragma" content="no-cache" /><meta http-equiv="cache-control" content="no-cache" /><meta http-equiv="expires" content="0" /><title>

</title></head>
<body>
    <form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMTAzMDE5NjQzD2QWAgIDD2QWAgIBDxYCHgtfIUl0ZW1Db3VudAIKZGT2cAOzJfxpNL5A5ZukofehnvKlWA==" />
</div>

<div>
	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCwLHtPKaCALdisw7ArqKzDsCm4zMOwKAjMw7AtmJzDsCtonMOwKXi8w7AvyKzDsClYnMOwLyiMw7BarzwEHb/hvG9W+neVi/ii77N7M=" />
</div>

            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
            <input name="bbb" type="text" id="bbb" />
    </form>

</body>
</html>
```

希望している結果は
```
<input name="aaa$ctl00$bbb" type="text" id="aaa_ctl00_bbb" />
```
なのですが…