で、私は10個の動的に生成するLinkButton要素を持つASP.NETページを持って更新します。ユーザーがこれらのLinkButton要素の1つをクリックすると、そのテキストをモーダルダイアログに表示します。ユーザーは、TextBoxに値を入力することによってテキストを変更できます。このための私のコードは次のようになります。このASP.NETコードのASP.NET - 防止ページModalPopupExtender
<asp:ScriptManager ID="theScriptManager" runat="server" />
<asp:UpdatePanel ID="myUpdatePanel" runat="server">
<ContentTemplate>
<asp:Table ID="myTable" runat="server" OnInit="myTable_Init" CellPadding="10" CellSpacing="10" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:LinkButton ID="testLinkButton" runat="server" />
<cc1:ModalPopupExtender ID="myPopupExtender" runat="server" TargetControlID="testLinkButton"
OkControlID="okButton" PopupControlID="myPanel" />
<asp:Panel ID="myPanel" runat="server" Style="display: none;">
<table border="1" cellpadding="0" cellspacing="0"><tr><td>
<table border="0" cellpadding="0" cellspacing="0" style="width: 300px;">
<tr><td colspan="2" style="background-color: Blue; font-weight: bold; color: White;">
Test
</td></tr>
<tr>
<td>You clicked <asp:TextBox ID="numTextBox" runat="server" MaxLength="3" />.</td>
<td align="right" style="padding-top: 5px; padding-bottom: 5px;">
<asp:Button ID="okButton" runat="server" Text="OK" OnClick="okButton_Click" />
</td>
</tr>
</table>
</td></tr></table>
</asp:Panel>
私のビハインドコードは、次のようになります。
private LinkButton selectedLinkButton = null;
protected void Page_Load(object sender, EventArgs e)
{}
protected void myTable_Init(object sender, EventArgs e)
{
TableRow row = new TableRow();
for (int i = 1; i < 11; i++)
{
LinkButton linkButton = new LinkButton();
linkButton.Text = i.ToString();
linkButton.Click += new EventHandler(linkButton_Click);
linkButton.CommandArgument = i.ToString();
AddLinkButtonToRow(linkButton, row);
}
myTable.Rows.Add(row);
}
protected void linkButton_Click(object sender, EventArgs e)
{
selectedLinkButton = (LinkButton)(sender);
numTextBox.Text = selectedLinkButton.CommandArgument;
myPopupExtender.Show();
}
protected void okButton_Click(object sender, EventArgs e)
{
if (selectedLinkButton != null)
{
selectedLinkButton.Text = numTextBox.Text.Trim();
}
}
private void AddLinkButtonToRow(LinkButton linkButton, TableRow row)
{
TableCell cell = new TableCell();
cell.Controls.Add(linkButton);
row.Cells.Add(cell);
}
私の問題は、私はポストバックの数を減らしたい、です。これを達成するために、私はASP.NET AJAXツールキットを使用することに決めました。残念ながら、私は、ユーザーがダイアログで「OK」をクリック後のLinkButtonのテキストを更新すると任意の成功を持っていないです。さらに、私はまだポストバックを取得しているようです。どのように私はこれを間違って使用していますか?
は、デフォルトでは、